diff options
| author | Nick Sandonato | 2012-10-24 18:49:19 +0000 |
|---|---|---|
| committer | Nick Sandonato | 2012-10-24 18:49:19 +0000 |
| commit | 1c861a2e4abcdeeddb228c3bbcefe80d8f72abbe (patch) | |
| tree | d97753912c177cbd54bae828955e204cbf349a0b | |
| parent | b134b4c133db1fe67de5ed127ad2410984feda8e (diff) | |
| download | webtools.sourceediting-1c861a2e4abcdeeddb228c3bbcefe80d8f72abbe.tar.gz webtools.sourceediting-1c861a2e4abcdeeddb228c3bbcefe80d8f72abbe.tar.xz webtools.sourceediting-1c861a2e4abcdeeddb228c3bbcefe80d8f72abbe.zip | |
[237567] [document] html editor mishandles encoding - it may destroy filev201210241849
| -rw-r--r-- | bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/EncodingGuesser.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/EncodingGuesser.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/EncodingGuesser.java index 7656fba0e1..bdbb65ae02 100644 --- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/EncodingGuesser.java +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/contenttype/EncodingGuesser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2011 IBM Corporation and others. + * Copyright (c) 2001, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.wst.html.core.internal.contenttype; + + /** * * This is ported from PageDesigner's hpbcom/Kanji.cpp's @@ -68,6 +70,8 @@ public class EncodingGuesser { */ private static final int UNKNOWN = -1; // Unknown + private static final boolean IS_GUESSING_ENABLED = isGuessingEnabled(); + /** * @return java.lang.String * @param code @@ -98,12 +102,20 @@ public class EncodingGuesser { } public static boolean canGuess() { + if (!IS_GUESSING_ENABLED) { + return false; + } // Currently, only Japanese is supported. String system_ctype = java.util.Locale.getDefault().getLanguage(); String jp_ctype = java.util.Locale.JAPANESE.getLanguage(); return system_ctype.compareTo(jp_ctype) == 0; } + private static boolean isGuessingEnabled() { + String value = System.getProperty("org.eclipse.wst.sse.html.encoding.guess"); + return value == null || Boolean.valueOf(value).booleanValue(); + } + /** * Return guessed Java Encoding name target: bytes to be inspected length: * length of target @@ -135,8 +147,12 @@ public class EncodingGuesser { case EUC_JP : code = EUC_JP; break; - default : + case SHIFT_JIS : + case SJIS_HALFKANA : code = SHIFT_JIS; + break; + default : + return null; } } return (convertToIANAEncodingName(code)); |
