-/*\r
+/*\r
* Copyright 2008 ZXing authors\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
+using System;\r
namespace com.google.zxing.common\r
{\r
- using System;\r
- using System.Text;\r
- using System.Collections;\r
-\r
- /// <summary> A class which wraps a 2D array of bytes. The default usage is signed. If you want to use it as a\r
- /// unsigned container, it's up to you to do byteValue & 0xff at each location.\r
- /// *\r
- /// JAVAPORT: I'm not happy about the argument ordering throughout the file, as I always like to have\r
- /// the horizontal component first, but this is for compatibility with the C++ code. The original\r
- /// code was a 2D array of ints, but since it only ever gets assigned -1, 0, and 1, I'm going to use\r
- /// less memory and go with bytes.\r
- /// *\r
- /// </summary>\r
- /// <author> dswitkin@google.com (Daniel Switkin)\r
- /// \r
- /// </author>\r
- public sealed class CharacterSetECI : ECI\r
- { \r
- private static Hashtable VALUE_TO_ECI=new Hashtable(29);\r
- /*static VALUE_TO_ECI = new Hashtable(29){\r
- // TODO figure out if these values are even right!\r
- addCharacterSet(0, "Cp437");\r
- addCharacterSet(1, "ISO8859_1");\r
- addCharacterSet(2, "Cp437");\r
- addCharacterSet(3, "ISO8859_1");\r
- addCharacterSet(4, "ISO8859_2");\r
- addCharacterSet(5, "ISO8859_3");\r
- addCharacterSet(6, "ISO8859_4");\r
- addCharacterSet(7, "ISO8859_5");\r
- addCharacterSet(8, "ISO8859_6");\r
- addCharacterSet(9, "ISO8859_7");\r
- addCharacterSet(10, "ISO8859_8");\r
- addCharacterSet(11, "ISO8859_9");\r
- addCharacterSet(12, "ISO8859_10");\r
- addCharacterSet(13, "ISO8859_11");\r
- addCharacterSet(15, "ISO8859_13");\r
- addCharacterSet(16, "ISO8859_14");\r
- addCharacterSet(17, "ISO8859_15");\r
- addCharacterSet(18, "ISO8859_16");\r
- addCharacterSet(20, "SJIS");\r
- }*/\r
-\r
- private String encodingName;\r
- \r
- private CharacterSetECI(int value, String encodingName):base(value) {\r
- addCharacterSet(0, "Cp437");\r
- addCharacterSet(1, "ISO8859_1");\r
- addCharacterSet(2, "Cp437");\r
- addCharacterSet(3, "ISO8859_1");\r
- addCharacterSet(4, "ISO8859_2");\r
- addCharacterSet(5, "ISO8859_3");\r
- addCharacterSet(6, "ISO8859_4");\r
- addCharacterSet(7, "ISO8859_5");\r
- addCharacterSet(8, "ISO8859_6");\r
- addCharacterSet(9, "ISO8859_7");\r
- addCharacterSet(10, "ISO8859_8");\r
- addCharacterSet(11, "ISO8859_9");\r
- addCharacterSet(12, "ISO8859_10");\r
- addCharacterSet(13, "ISO8859_11");\r
- addCharacterSet(15, "ISO8859_13");\r
- addCharacterSet(16, "ISO8859_14");\r
- addCharacterSet(17, "ISO8859_15");\r
- addCharacterSet(18, "ISO8859_16");\r
- addCharacterSet(20, "SJIS");\r
- this.encodingName = encodingName;\r
- }\r
-\r
- public String getEncodingName() {\r
- return encodingName;\r
- }\r
-\r
- private static void addCharacterSet(int value, String encodingName) {\r
- VALUE_TO_ECI.Add(value, new CharacterSetECI(value, encodingName));\r
- }\r
-\r
- public static CharacterSetECI getCharacterSetECIByValue(int value) { \r
- CharacterSetECI eci = (CharacterSetECI) VALUE_TO_ECI[value];\r
- if (eci == null) {\r
- throw new Exception("Unsupported value: " + value);\r
- }\r
- return eci;\r
- }\r
- }\r
+ \r
+ /// <summary> Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1\r
+ /// of ISO 18004.\r
+ /// \r
+ /// </summary>\r
+ /// <author> Sean Owen\r
+ /// </author>\r
+ /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
+ /// </author>\r
+ public sealed class CharacterSetECI:ECI\r
+ {\r
+ public System.String EncodingName\r
+ {\r
+ get\r
+ {\r
+ return encodingName;\r
+ }\r
+ \r
+ }\r
+ \r
+ private static System.Collections.Hashtable VALUE_TO_ECI;\r
+ private static System.Collections.Hashtable NAME_TO_ECI;\r
+ \r
+ private static void initialize()\r
+ {\r
+ VALUE_TO_ECI = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable(29));\r
+ NAME_TO_ECI = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable(29));\r
+ // TODO figure out if these values are even right!\r
+ addCharacterSet(0, "Cp437");\r
+ addCharacterSet(1, new System.String[]{"ISO8859_1", "ISO-8859-1"});\r
+ addCharacterSet(2, "Cp437");\r
+ addCharacterSet(3, new System.String[]{"ISO8859_1", "ISO-8859-1"});\r
+ addCharacterSet(4, "ISO8859_2");\r
+ addCharacterSet(5, "ISO8859_3");\r
+ addCharacterSet(6, "ISO8859_4");\r
+ addCharacterSet(7, "ISO8859_5");\r
+ addCharacterSet(8, "ISO8859_6");\r
+ addCharacterSet(9, "ISO8859_7");\r
+ addCharacterSet(10, "ISO8859_8");\r
+ addCharacterSet(11, "ISO8859_9");\r
+ addCharacterSet(12, "ISO8859_10");\r
+ addCharacterSet(13, "ISO8859_11");\r
+ addCharacterSet(15, "ISO8859_13");\r
+ addCharacterSet(16, "ISO8859_14");\r
+ addCharacterSet(17, "ISO8859_15");\r
+ addCharacterSet(18, "ISO8859_16");\r
+ addCharacterSet(20, new System.String[]{"SJIS", "Shift_JIS"});\r
+ }\r
+ \r
+ //UPGRADE_NOTE: Final was removed from the declaration of 'encodingName '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
+ private System.String encodingName;\r
+ \r
+ private CharacterSetECI(int value_Renamed, System.String encodingName):base(value_Renamed)\r
+ {\r
+ this.encodingName = encodingName;\r
+ }\r
+ \r
+ private static void addCharacterSet(int value_Renamed, System.String encodingName)\r
+ {\r
+ CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingName);\r
+ VALUE_TO_ECI[(System.Int32) value_Renamed] = eci; // can't use valueOf\r
+ NAME_TO_ECI[encodingName] = eci;\r
+ }\r
+ \r
+ private static void addCharacterSet(int value_Renamed, System.String[] encodingNames)\r
+ {\r
+ CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingNames[0]);\r
+ VALUE_TO_ECI[(System.Int32) value_Renamed] = eci; // can't use valueOf\r
+ for (int i = 0; i < encodingNames.Length; i++)\r
+ {\r
+ NAME_TO_ECI[encodingNames[i]] = eci;\r
+ }\r
+ }\r
+ \r
+ /// <param name="value">character set ECI value\r
+ /// </param>\r
+ /// <returns> {@link CharacterSetECI} representing ECI of given value, or null if it is legal but\r
+ /// unsupported\r
+ /// </returns>\r
+ /// <throws> IllegalArgumentException if ECI value is invalid </throws>\r
+ public static CharacterSetECI getCharacterSetECIByValue(int value_Renamed)\r
+ {\r
+ if (VALUE_TO_ECI == null)\r
+ {\r
+ initialize();\r
+ }\r
+ if (value_Renamed < 0 || value_Renamed >= 900)\r
+ {\r
+ throw new System.ArgumentException("Bad ECI value: " + value_Renamed);\r
+ }\r
+ return (CharacterSetECI) VALUE_TO_ECI[(System.Int32) value_Renamed];\r
+ }\r
+ \r
+ /// <param name="name">character set ECI encoding name\r
+ /// </param>\r
+ /// <returns> {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal\r
+ /// but unsupported\r
+ /// </returns>\r
+ public static CharacterSetECI getCharacterSetECIByName(System.String name)\r
+ {\r
+ if (NAME_TO_ECI == null)\r
+ {\r
+ initialize();\r
+ }\r
+ return (CharacterSetECI) NAME_TO_ECI[name];\r
+ }\r
+ }\r
}
\ No newline at end of file