- Русские Блоги
- Как использовать родной инструмент транскодирования native2ascii.exe
- Native2ascii java как использовать
- Parameters specified as nested elements
- arg
- implementationclasspath
- Any nested element of a type that implements Native2AsciiAdapter
- Examples
- native2ascii
- Synopsis
- Description
- Options
- Русские Блоги
- Формат команды native2ascii:
- Использование native2ascii:
- Native2ascii java как использовать
- Parameters specified as nested elements
- arg
- implementationclasspath since Apache Ant 1.8.0
- Any nested element of a type that implements Native2AsciiAdapter since Ant 1.8.0
- Examples
Русские Блоги
Как использовать родной инструмент транскодирования native2ascii.exe
1. Введение в native2ascii.exe:
Native2ascii — это инструмент транскодирования, предоставляемый Sun Java Java SDK, используемый для преобразования других текстовых файлов (таких как * .txt, * .ini, * .properties, * .java и т. Д.) В кодировку Unicode.
2. Как получить native2ascii.exe?
После установки jdk, если вы устанавливаете в Windows, в каталоге установки jdk будет каталог bin, и в нем будет находиться инструмент native2ascii.exe, который нам нужен.
3. Как использовать native2ascii.exe:
native2ascii -[options] [inputfile [outputfile]]
— [Опции]: указывает на переключатель команд, есть два варианта на выбор
-Reverse: преобразовать кодировку Unicode в локальную или указать кодировку. Если кодировка не указана, она будет преобразована в локальную кодировку.
Кодировка имя-кодировки: Преобразовать в указанную кодировку, имя-кодировки — это имя кодировки.
Inputfile: указывает полное имя входного файла.
Выходной файл: имя выходного файла. Если этот параметр отсутствует, он будет выведен на консоль.
Пример. Скопируйте файлы, которые необходимо интернационализировать (как показано ниже), в каталог C: \ Program Files \ Java \ jdk1.6.0_31 \ bin и используйте инструмент native2ascii.exe для перекодирования.
Используйте команду cmd для входа в окно команд DOS для следующих операций:
После успешного перекодирования с помощью команды native2ascii, как показано ниже:
Примечания: native2ascii.exe — относительно простой инструмент транскодирования, и перекодировка обратима.
Попробуйте следующую команду:
native2ascii -reverse new.txt yan.txt
native2ascii -encoding gbk old.txt new.txt
Native2ascii java как использовать
Converts files from native encodings to ASCII with escaped Unicode. A common usage is to convert source files maintained in a native operating system encoding, to ASCII prior to compilation.
Files in the directory src are converted from a native encoding to ASCII. By default, all files in the directory are converted. However, conversion may be limited to selected files using includes and excludes attributes. For more information on file matching patterns, see the section on directory based tasks. If no encoding is specified, the default encoding for the JVM is used. If ext is specified, then output files are renamed to use it as a new extension. More sophisticated file name translations can be achieved using a nested element. By default an identity mapper will be used. If dest and src point to the same directory, the ext attribute or a nested is required.
This task forms an implicit FileSet, and supports most attributes of ( dir becomes src ) as well as nested , , and elements.
It is possible to use different converters. This can be selected with the implementation attribute or a nested element. Here are the choices of the attribute:
- default —the default converter for the platform: kaffe when run on Kaffe, builtin otherwise.
- sun —used to be the standard converter of the JDK 8 or earlier
- kaffe —the standard converter of Kaffe
- builtin —Ant’s internal implementation. Since Ant 1.9.8
Parameters specified as nested elements
arg
You can specify additional command line arguments for the converter with nested elements. These elements are specified like Command-line Arguments but have an additional attribute that can be used to enable arguments only if a given converter implementation will be used.
Attribute | Description | Required |
---|---|---|
value | See Command-line Arguments. | Exactly one of these |
line | ||
file | ||
path | ||
implementation | Only pass the specified argument if the chosen converter implementation matches the value of this attribute. Legal values are the same as those in the above list of valid compilers.) | No |
implementationclasspath
A path-like structure holding the classpath to use when loading the converter implementation if a custom class has been specified. Doesn’t have any effect when using one of the built-in converters.
Any nested element of a type that implements Native2AsciiAdapter
If a defined type implements the Native2AsciiAdapter interface a nested element of that type can be used as an alternative to the implementation attribute.
Examples
Convert all files in the directory srcdir ending in .eucjis from the EUCJIS encoding to ASCII and rename them to end in .java .
Convert all the files ending in .java in the directory native/japanese to ASCII, placing the results in the directory src . The names of the files remain the same.
If you want to use a custom Native2AsciiAdapter org.example.MyAdapter you can either use the implementation attribute:
or a define a type and nest this into the task like in:
in which case your native2ascii adapter can support attributes and nested elements of its own.
native2ascii
Creates localizable applications by converting a file with characters in any supported character encoding to one with ASCII and/or Unicode escapes or vice versa.
Synopsis
native2ascii [ inputfile ] [ outputfile ]
The encoded file to be converted to ASCII.
Description
The native2ascii command converts encoded files supported by the Java Runtime Environment (JRE) to files encoded in ASCII, using Unicode escapes ( \u xxxx ) notation for all characters that are not part of the ASCII character set. This process is required for properties files that contain characters not in ISO-8859-1 character sets. The tool can also perform the reverse conversion.
If the outputfile value is omitted, then standard output is used for output. If, in addition, the inputfile value is omitted, then standard input is used for input.
Options
Perform the reverse operation: Converts a file encoded in ISO-8859-1 with Unicode escapes to a file in any character encoding supported by the JRE.
-encoding encoding_name
Specifies the name of the character encoding to be used by the conversion procedure. If this option is not present, then the default character encoding (as determined by the java.nio.charset.Charset.defaultCharset method) is used. The encoding_name string must be the name of a character encoding that is supported by the JRE. See Supported Encodings at
http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html
Passes option to the Java Virtual Machine (JVM), where option is one of the options described on the reference page for the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. See java (1).
Русские Блоги
native2ascii.exe — это инструмент транскодирования файлов для Java, который преобразует специальный и другой контент в унифицированное выражение с использованием указанного стандартного стиля кодирования. Обычно он находится в каталоге JDK_home \ bin (как показано ниже). После этого вы можете использовать команду native2ascii для транскодирования.
Формат команды native2ascii:
native2ascii -[options] [inputfile [outputfile]]
Описание:
— [options]: указывает на переключатель команд, есть два варианта на выбор
-reverse: преобразовать кодировку Unicode в локальную или указать кодировку, если кодировка не указана, она будет преобразована в локальную кодировку.
-encoding encoding_name: преобразовать в указанную кодировку, encoding_name — это имя кодировки.
inputfile: указывает полное имя входного файла.
outputfile: имя выходного файла. Если этот параметр отсутствует, он будет выведен на консоль.
Использование native2ascii:
Создайте тестовый файл: test.txt, введите китайский «тестовый файл» в тестовый файл и сохраните его. Введите следующую команду:
native2ascii test.txt testEncoding.txt // Файл кодирования native2ascii -reverse testEncoding.txt testUnEncoding.txt // декодировать в исходный файл
Окончательный результат выглядит следующим образом:
Native2ascii java как использовать
Converts files from native encodings to ASCII with escaped Unicode. A common usage is to convert source files maintained in a native operating system encoding, to ASCII prior to compilation.
Files in the directory src are converted from a native encoding to ASCII. By default, all files in the directory are converted. However, conversion may be limited to selected files using includes and excludes attributes. For more information on file matching patterns, see the section on directory based tasks. If no encoding is specified, the default encoding for the JVM is used. If ext is specified, then output files are renamed to use it as a new extension. More sophisticated file name translations can be achieved using a nested element. By default an identity mapper will be used. If dest and src point to the same directory, the ext attribute or a nested is required.
This task forms an implicit File Set, and supports most attributes of ( dir becomes src ) as well as nested , , and elements.
It is possible to use different converters. This can be selected with the implementation attribute or a nested element. Here are the choices of the attribute:
Parameters specified as nested elements
arg
You can specify additional command line arguments for the converter with nested elements. These elements are specified like Command-line Arguments but have an additional attribute that can be used to enable arguments only if a given converter implementation will be used.
implementationclasspath since Apache Ant 1.8.0
A PATH like structure holding the classpath to use when loading the converter implementation if a custom class has been specified. Doesn’t have any effect when using one of the built-in converters.
Any nested element of a type that implements Native2AsciiAdapter since Ant 1.8.0
If a defined type implements the Native2AsciiAdapter interface a nested element of that type can be used as an alternative to the implementation attribute.
Examples
Converts all files in the directory srcdir ending in .eucjis from the EUCJIS encoding to ASCII and renames them to end in .java .
Converts all the files ending in .java in the directory native/japanese to ASCII, placing the results in the directory src. The names of the files remain the same.
If you want to use a custom Native2AsciiAdapter org.example.MyAdapter you can either use the implementation attribute:
or a define a type and nest this into the task like in:
in which case your native2ascii adapter can support attributes and nested elements of its own.