Java - native2asciiで中国語をUnicodeに変換する

Java – native2asciiを使用して中国語の文字をUnicodeに変換する

native2asciiはJDKの便利なツールビルトインで、「非ラテン1」または「非Unicode」文字のファイルを「Unicodeエンコード」文字に変換するために使用されます。

Native2asciiの例

1. ファイルを作成する(source.txt)

「source.txt」という名前のファイルを作成し、中にいくつかの漢字とsave it as “UTF-8” formatを入れます。

image

2. native2ascii

native2asciiコマンドを使用して、Unicode形式に変換します。

C:\>native2ascii -encoding utf8 c:\source.txt c:\output.txt

native2asciiは、「c:\ source.txt」からすべての文字を読み取り、「utf8」形式でエンコードし、エンコードされたすべての文字を「c:\ output.txt」に出力します

3. 出力を読む

Open the “c:\output.txt”, you will see the all encoded characters, e.g 杨木金

image