CharacterSetECI.java (zxing-zxing-3.4.1) | : | CharacterSetECI.java (zxing-zxing-3.5.0) | ||
---|---|---|---|---|
skipping to change at line 21 | skipping to change at line 21 | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | |||
* limitations under the License. | * limitations under the License. | |||
*/ | */ | |||
package com.google.zxing.common; | package com.google.zxing.common; | |||
import com.google.zxing.FormatException; | import com.google.zxing.FormatException; | |||
import java.nio.charset.Charset; | ||||
import java.util.HashMap; | import java.util.HashMap; | |||
import java.util.Map; | import java.util.Map; | |||
/** | /** | |||
* Encapsulates a Character Set ECI, according to "Extended Channel Interpretati ons" 5.3.1.1 | * Encapsulates a Character Set ECI, according to "Extended Channel Interpretati ons" 5.3.1.1 | |||
* of ISO 18004. | * of ISO 18004. | |||
* | * | |||
* @author Sean Owen | * @author Sean Owen | |||
*/ | */ | |||
public enum CharacterSetECI { | public enum CharacterSetECI { | |||
// Enum name is a Java encoding valid for java.lang and java.io | // Enum name is a Java encoding valid for java.lang and java.io | |||
Cp437(new int[]{0,2}), | Cp437(new int[]{0,2}), | |||
ISO8859_1(new int[]{1,3}, "ISO-8859-1"), | ISO8859_1(new int[]{1,3}, "ISO-8859-1"), | |||
ISO8859_2(4, "ISO-8859-2"), | ISO8859_2(4, "ISO-8859-2"), | |||
ISO8859_3(5, "ISO-8859-3"), | ISO8859_3(5, "ISO-8859-3"), | |||
ISO8859_4(6, "ISO-8859-4"), | ISO8859_4(6, "ISO-8859-4"), | |||
ISO8859_5(7, "ISO-8859-5"), | ISO8859_5(7, "ISO-8859-5"), | |||
ISO8859_6(8, "ISO-8859-6"), | // ISO8859_6(8, "ISO-8859-6"), | |||
ISO8859_7(9, "ISO-8859-7"), | ISO8859_7(9, "ISO-8859-7"), | |||
ISO8859_8(10, "ISO-8859-8"), | // ISO8859_8(10, "ISO-8859-8"), | |||
ISO8859_9(11, "ISO-8859-9"), | ISO8859_9(11, "ISO-8859-9"), | |||
ISO8859_10(12, "ISO-8859-10"), | // ISO8859_10(12, "ISO-8859-10"), | |||
ISO8859_11(13, "ISO-8859-11"), | // ISO8859_11(13, "ISO-8859-11"), | |||
ISO8859_13(15, "ISO-8859-13"), | ISO8859_13(15, "ISO-8859-13"), | |||
ISO8859_14(16, "ISO-8859-14"), | // ISO8859_14(16, "ISO-8859-14"), | |||
ISO8859_15(17, "ISO-8859-15"), | ISO8859_15(17, "ISO-8859-15"), | |||
ISO8859_16(18, "ISO-8859-16"), | ISO8859_16(18, "ISO-8859-16"), | |||
SJIS(20, "Shift_JIS"), | SJIS(20, "Shift_JIS"), | |||
Cp1250(21, "windows-1250"), | Cp1250(21, "windows-1250"), | |||
Cp1251(22, "windows-1251"), | Cp1251(22, "windows-1251"), | |||
Cp1252(23, "windows-1252"), | Cp1252(23, "windows-1252"), | |||
Cp1256(24, "windows-1256"), | Cp1256(24, "windows-1256"), | |||
UnicodeBigUnmarked(25, "UTF-16BE", "UnicodeBig"), | UnicodeBigUnmarked(25, "UTF-16BE", "UnicodeBig"), | |||
UTF8(26, "UTF-8"), | UTF8(26, "UTF-8"), | |||
ASCII(new int[] {27, 170}, "US-ASCII"), | ASCII(new int[] {27, 170}, "US-ASCII"), | |||
skipping to change at line 96 | skipping to change at line 98 | |||
CharacterSetECI(int[] values, String... otherEncodingNames) { | CharacterSetECI(int[] values, String... otherEncodingNames) { | |||
this.values = values; | this.values = values; | |||
this.otherEncodingNames = otherEncodingNames; | this.otherEncodingNames = otherEncodingNames; | |||
} | } | |||
public int getValue() { | public int getValue() { | |||
return values[0]; | return values[0]; | |||
} | } | |||
public Charset getCharset() { | ||||
return Charset.forName(name()); | ||||
} | ||||
/** | ||||
* @param charset Java character set object | ||||
* @return CharacterSetECI representing ECI for character encoding, or null if | ||||
it is legal | ||||
* but unsupported | ||||
*/ | ||||
public static CharacterSetECI getCharacterSetECI(Charset charset) { | ||||
return NAME_TO_ECI.get(charset.name()); | ||||
} | ||||
/** | /** | |||
* @param value character set ECI value | * @param value character set ECI value | |||
* @return {@code CharacterSetECI} representing ECI of given value, or null if it is legal but | * @return {@code CharacterSetECI} representing ECI of given value, or null if it is legal but | |||
* unsupported | * unsupported | |||
* @throws FormatException if ECI value is invalid | * @throws FormatException if ECI value is invalid | |||
*/ | */ | |||
public static CharacterSetECI getCharacterSetECIByValue(int value) throws Form atException { | public static CharacterSetECI getCharacterSetECIByValue(int value) throws Form atException { | |||
if (value < 0 || value >= 900) { | if (value < 0 || value >= 900) { | |||
throw FormatException.getFormatInstance(); | throw FormatException.getFormatInstance(); | |||
} | } | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 21 lines changed or added |