Browse Source

remove ECI

tags/2.3
clowwindy 9 years ago
parent
commit
c2f7145980
4 changed files with 6 additions and 212 deletions
  1. +0
    -128
      shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs
  2. +0
    -66
      shadowsocks-csharp/3rd/zxing/common/ECI.cs
  3. +6
    -16
      shadowsocks-csharp/3rd/zxing/qrcode/decoder/DecodedBitStreamParser.cs
  4. +0
    -2
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 0
- 128
shadowsocks-csharp/3rd/zxing/common/CharacterSetECI.cs View File

@@ -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
{
/// <summary> Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1
/// of ISO 18004.
///
/// </summary>
/// <author>Sean Owen</author>
public sealed class CharacterSetECI : ECI
{
internal static readonly IDictionary<int, CharacterSetECI> VALUE_TO_ECI;
internal static readonly IDictionary<string, CharacterSetECI> NAME_TO_ECI;
private readonly String encodingName;
public String EncodingName
{
get
{
return encodingName;
}
}
static CharacterSetECI()
{
VALUE_TO_ECI = new Dictionary<int, CharacterSetECI>();
NAME_TO_ECI = new Dictionary<string, CharacterSetECI>();
// 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;
}
}
/// <param name="value">character set ECI value
/// </param>
/// <returns> {@link CharacterSetECI} representing ECI of given value, or null if it is legal but
/// unsupported
/// </returns>
/// <throws> IllegalArgumentException if ECI value is invalid </throws>
public static CharacterSetECI getCharacterSetECIByValue(int value)
{
if (value < 0 || value >= 900)
{
return null;
}
return VALUE_TO_ECI[value];
}
/// <param name="name">character set ECI encoding name
/// </param>
/// <returns> {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal
/// but unsupported
/// </returns>
public static CharacterSetECI getCharacterSetECIByName(String name)
{
return NAME_TO_ECI[name.ToUpper()];
}
}
}

+ 0
- 66
shadowsocks-csharp/3rd/zxing/common/ECI.cs View File

@@ -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
{
/// <summary> Superclass of classes encapsulating types ECIs, according to "Extended Channel Interpretations"
/// 5.3 of ISO 18004.
///
/// </summary>
/// <author> Sean Owen
/// </author>
/// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
/// </author>
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;
}
/// <param name="value">ECI value
/// </param>
/// <returns> {@link ECI} representing ECI of given value, or null if it is legal but unsupported
/// </returns>
/// <throws> IllegalArgumentException if ECI value is invalid </throws>
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;
}
}
}

+ 6
- 16
shadowsocks-csharp/3rd/zxing/qrcode/decoder/DecodedBitStreamParser.cs View File

@@ -54,7 +54,7 @@ namespace ZXing.QrCode.Internal
try try
{ {
CharacterSetECI currentCharacterSetECI = null;
// CharacterSetECI currentCharacterSetECI = null;
bool fc1InEffect = false; bool fc1InEffect = false;
Mode mode; Mode mode;
do do
@@ -96,6 +96,7 @@ namespace ZXing.QrCode.Internal
} }
else if (mode == Mode.ECI) else if (mode == Mode.ECI)
{ {
/*
// Count doesn't apply to ECI // Count doesn't apply to ECI
int value = parseECIValue(bits); int value = parseECIValue(bits);
currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value);
@@ -103,6 +104,7 @@ namespace ZXing.QrCode.Internal
{ {
return null; return null;
} }
* */
} }
else else
{ {
@@ -135,7 +137,7 @@ namespace ZXing.QrCode.Internal
} }
else if (mode == Mode.BYTE) else if (mode == Mode.BYTE)
{ {
if (!decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints))
if (!decodeByteSegment(bits, result, count, byteSegments, hints))
return null; return null;
} }
else if (mode == Mode.KANJI) else if (mode == Mode.KANJI)
@@ -301,7 +303,6 @@ namespace ZXing.QrCode.Internal
private static bool decodeByteSegment(BitSource bits, private static bool decodeByteSegment(BitSource bits,
StringBuilder result, StringBuilder result,
int count, int count,
CharacterSetECI currentCharacterSetECI,
IList<byte[]> byteSegments, IList<byte[]> byteSegments,
IDictionary<DecodeHintType, object> hints) IDictionary<DecodeHintType, object> hints)
{ {
@@ -317,19 +318,8 @@ namespace ZXing.QrCode.Internal
readBytes[i] = (byte)bits.readBits(8); readBytes[i] = (byte)bits.readBits(8);
} }
String encoding; 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 try
{ {
result.Append(Encoding.GetEncoding(encoding).GetString(readBytes, 0, readBytes.Length)); result.Append(Encoding.GetEncoding(encoding).GetString(readBytes, 0, readBytes.Length));


+ 0
- 2
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -78,12 +78,10 @@
<Compile Include="3rd\zxing\common\BitArray.cs" /> <Compile Include="3rd\zxing\common\BitArray.cs" />
<Compile Include="3rd\zxing\common\BitMatrix.cs" /> <Compile Include="3rd\zxing\common\BitMatrix.cs" />
<Compile Include="3rd\zxing\common\BitSource.cs" /> <Compile Include="3rd\zxing\common\BitSource.cs" />
<Compile Include="3rd\zxing\common\CharacterSetECI.cs" />
<Compile Include="3rd\zxing\common\DecoderResult.cs" /> <Compile Include="3rd\zxing\common\DecoderResult.cs" />
<Compile Include="3rd\zxing\common\DefaultGridSampler.cs" /> <Compile Include="3rd\zxing\common\DefaultGridSampler.cs" />
<Compile Include="3rd\zxing\common\DetectorResult.cs" /> <Compile Include="3rd\zxing\common\DetectorResult.cs" />
<Compile Include="3rd\zxing\common\detector\MathUtils.cs" /> <Compile Include="3rd\zxing\common\detector\MathUtils.cs" />
<Compile Include="3rd\zxing\common\ECI.cs" />
<Compile Include="3rd\zxing\common\GlobalHistogramBinarizer.cs" /> <Compile Include="3rd\zxing\common\GlobalHistogramBinarizer.cs" />
<Compile Include="3rd\zxing\common\GridSampler.cs" /> <Compile Include="3rd\zxing\common\GridSampler.cs" />
<Compile Include="3rd\zxing\common\HybridBinarizer.cs" /> <Compile Include="3rd\zxing\common\HybridBinarizer.cs" />


Loading…
Cancel
Save