Unicode to Java char convertion

ShaileshShinde
ShaileshShinde used Ask the Experts™
on
Hello Experts,

There is an requirement for converting translated strings into java chars[\u00f7] using Java or Perl Script, VBScript. The script should recognize the language and convert the strings into java chars.

Can you please provide any references or sample codes to do this?


Thanks,
Shail
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
I'm not clear what the requirement is (java String is essentially a wrapper round an array of char anyway) so please provide sample input as an attachment

Author

Commented:
The example is below...

Chinese Characters [¿¿¿¿]
Converted to java chars [\u505A\u696D\u540D\u7A31]

Thanks,
Shail

Author

Commented:
Please find attached sample file.
u505A.docx
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Top Expert 2016
Commented:
Save your input as a text file. You can then use the JDK utility 'native2ascii' on it:

native2ascii u505A.txt esc.txt

Open in new window


Output is a file containing


\ufeff\u505a\u696d\u540d\u7a31

(You can ignore the first if you find it - it's the 'BOM')

Author

Commented:
Hello Experts,

Couple of queries:

1> This utility will applies for all languages?
2> It supports only .txt files or any other file formats?

I just tried with Chinese characters .txt file and it works as required.

However, we do have other file formats and not just .txt files.

Thanks,
Shail
Top Expert 2016

Commented:
However, we do have other file formats and not just .txt files.
Reading a word processing file is not the job of a utility like native2ascii - it's the job of a word processing program and therefore a separate problem

Author

Commented:
Thanks Expert!
Top Expert 2016

Commented:
:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial