From c2f714598002d7e16a44522970da9deab2edf194 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Tue, 13 Jan 2015 02:12:22 +0800 Subject: [PATCH] remove ECI --- .../3rd/zxing/common/CharacterSetECI.cs | 128 ------------------ shadowsocks-csharp/3rd/zxing/common/ECI.cs | 66 --------- .../qrcode/decoder/DecodedBitStreamParser.cs | 22 +-- shadowsocks-csharp/shadowsocks-csharp.csproj | 2 - 4 files changed, 6 insertions(+), 212 deletions(-) delete mode 100755 shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs delete mode 100755 shadowsocks-csharp/3rd/zxing/common/ECI.cs diff --git a/shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs b/shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs deleted file mode 100755 index cb42eb5f..00000000 --- a/shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs +++ /dev/null @@ -1,128 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -namespace ZXing.Common -{ - /// Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1 - /// of ISO 18004. - /// - /// - /// Sean Owen - public sealed class CharacterSetECI : ECI - { - internal static readonly IDictionary VALUE_TO_ECI; - internal static readonly IDictionary NAME_TO_ECI; - - private readonly String encodingName; - - public String EncodingName - { - get - { - return encodingName; - } - - } - - static CharacterSetECI() - { - VALUE_TO_ECI = new Dictionary(); - NAME_TO_ECI = new Dictionary(); - // TODO figure out if these values are even right! - addCharacterSet(0, "CP437"); - addCharacterSet(1, new[] { "ISO-8859-1", "ISO8859_1" }); - addCharacterSet(2, "CP437"); - addCharacterSet(3, new[] { "ISO-8859-1", "ISO8859_1" }); - addCharacterSet(4, new[] { "ISO-8859-2", "ISO8859_2" }); - addCharacterSet(5, new[] { "ISO-8859-3", "ISO8859_3" }); - addCharacterSet(6, new[] { "ISO-8859-4", "ISO8859_4" }); - addCharacterSet(7, new[] { "ISO-8859-5", "ISO8859_5" }); - addCharacterSet(8, new[] { "ISO-8859-6", "ISO8859_6" }); - addCharacterSet(9, new[] { "ISO-8859-7", "ISO8859_7" }); - addCharacterSet(10, new[] { "ISO-8859-8", "ISO8859_8" }); - addCharacterSet(11, new[] { "ISO-8859-9", "ISO8859_9" }); - addCharacterSet(12, new[] { "ISO-8859-4", "ISO-8859-10", "ISO8859_10" }); // use ISO-8859-4 because ISO-8859-16 isn't supported - addCharacterSet(13, new[] { "ISO-8859-11", "ISO8859_11" }); - addCharacterSet(15, new[] { "ISO-8859-13", "ISO8859_13" }); - addCharacterSet(16, new[] { "ISO-8859-1", "ISO-8859-14", "ISO8859_14" }); // use ISO-8859-1 because ISO-8859-16 isn't supported - addCharacterSet(17, new[] { "ISO-8859-15", "ISO8859_15" }); - addCharacterSet(18, new[] { "ISO-8859-3", "ISO-8859-16", "ISO8859_16" }); // use ISO-8859-3 because ISO-8859-16 isn't supported - addCharacterSet(20, new[] { "SJIS", "Shift_JIS" }); - addCharacterSet(21, new[] { "WINDOWS-1250", "CP1250" }); - addCharacterSet(22, new[] { "WINDOWS-1251", "CP1251" }); - addCharacterSet(23, new[] { "WINDOWS-1252", "CP1252" }); - addCharacterSet(24, new[] { "WINDOWS-1256", "CP1256" }); - addCharacterSet(25, new[] { "UTF-16BE", "UNICODEBIG" }); - addCharacterSet(26, new[] { "UTF-8", "UTF8" }); - addCharacterSet(27, "US-ASCII"); - addCharacterSet(170, "US-ASCII"); - addCharacterSet(28, "BIG5"); - addCharacterSet(29, new[] { "GB18030", "GB2312", "EUC_CN", "GBK" }); - addCharacterSet(30, new[] { "EUC-KR", "EUC_KR" }); - } - - private CharacterSetECI(int value, String encodingName) - : base(value) - { - this.encodingName = encodingName; - } - - private static void addCharacterSet(int value, String encodingName) - { - var eci = new CharacterSetECI(value, encodingName); - VALUE_TO_ECI[value] = eci; // can't use valueOf - NAME_TO_ECI[encodingName] = eci; - } - - private static void addCharacterSet(int value, String[] encodingNames) - { - var eci = new CharacterSetECI(value, encodingNames[0]); - VALUE_TO_ECI[value] = eci; // can't use valueOf - foreach (string t in encodingNames) - { - NAME_TO_ECI[t] = eci; - } - } - - /// character set ECI value - /// - /// {@link CharacterSetECI} representing ECI of given value, or null if it is legal but - /// unsupported - /// - /// IllegalArgumentException if ECI value is invalid - public static CharacterSetECI getCharacterSetECIByValue(int value) - { - if (value < 0 || value >= 900) - { - return null; - } - return VALUE_TO_ECI[value]; - } - - /// character set ECI encoding name - /// - /// {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal - /// but unsupported - /// - public static CharacterSetECI getCharacterSetECIByName(String name) - { - return NAME_TO_ECI[name.ToUpper()]; - } - } -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/common/ECI.cs b/shadowsocks-csharp/3rd/zxing/common/ECI.cs deleted file mode 100755 index fa947ba2..00000000 --- a/shadowsocks-csharp/3rd/zxing/common/ECI.cs +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -using System; -namespace ZXing.Common -{ - - /// Superclass of classes encapsulating types ECIs, according to "Extended Channel Interpretations" - /// 5.3 of ISO 18004. - /// - /// - /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - public abstract class ECI - { - virtual public int Value - { - get - { - return value_Renamed; - } - - } - - //UPGRADE_NOTE: Final was removed from the declaration of 'value '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'" - private int value_Renamed; - - internal ECI(int value_Renamed) - { - this.value_Renamed = value_Renamed; - } - - /// ECI value - /// - /// {@link ECI} representing ECI of given value, or null if it is legal but unsupported - /// - /// IllegalArgumentException if ECI value is invalid - public static ECI getECIByValue(int value_Renamed) - { - if (value_Renamed < 0 || value_Renamed > 999999) - { - throw new System.ArgumentException("Bad ECI value: " + value_Renamed); - } - if (value_Renamed < 900) - { - // Character set ECIs use 000000 - 000899 - return CharacterSetECI.getCharacterSetECIByValue(value_Renamed); - } - return null; - } - } -} \ No newline at end of file diff --git a/shadowsocks-csharp/3rd/zxing/qrcode/decoder/DecodedBitStreamParser.cs b/shadowsocks-csharp/3rd/zxing/qrcode/decoder/DecodedBitStreamParser.cs index 77a0b2cc..189fb41f 100755 --- a/shadowsocks-csharp/3rd/zxing/qrcode/decoder/DecodedBitStreamParser.cs +++ b/shadowsocks-csharp/3rd/zxing/qrcode/decoder/DecodedBitStreamParser.cs @@ -54,7 +54,7 @@ namespace ZXing.QrCode.Internal try { - CharacterSetECI currentCharacterSetECI = null; + // CharacterSetECI currentCharacterSetECI = null; bool fc1InEffect = false; Mode mode; do @@ -96,6 +96,7 @@ namespace ZXing.QrCode.Internal } else if (mode == Mode.ECI) { + /* // Count doesn't apply to ECI int value = parseECIValue(bits); currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); @@ -103,6 +104,7 @@ namespace ZXing.QrCode.Internal { return null; } + * */ } else { @@ -135,7 +137,7 @@ namespace ZXing.QrCode.Internal } else if (mode == Mode.BYTE) { - if (!decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints)) + if (!decodeByteSegment(bits, result, count, byteSegments, hints)) return null; } else if (mode == Mode.KANJI) @@ -301,7 +303,6 @@ namespace ZXing.QrCode.Internal private static bool decodeByteSegment(BitSource bits, StringBuilder result, int count, - CharacterSetECI currentCharacterSetECI, IList byteSegments, IDictionary hints) { @@ -317,19 +318,8 @@ namespace ZXing.QrCode.Internal readBytes[i] = (byte)bits.readBits(8); } String encoding; - if (currentCharacterSetECI == null) - { - // The spec isn't clear on this mode; see - // section 6.4.5: t does not say which encoding to assuming - // upon decoding. I have seen ISO-8859-1 used as well as - // Shift_JIS -- without anything like an ECI designator to - // give a hint. - encoding = StringUtils.guessEncoding(readBytes, hints); - } - else - { - encoding = currentCharacterSetECI.EncodingName; - } + encoding = StringUtils.guessEncoding(readBytes, hints); + try { result.Append(Encoding.GetEncoding(encoding).GetString(readBytes, 0, readBytes.Length)); diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index cd5b2683..e5da1098 100755 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -78,12 +78,10 @@ - -