0

Use Case: I have a client server setup where server is a Solaris machine and client can be any windows, linux, etc. Client while coming up needs to create a resource bundle object based on client's locale which in turn fetches a Chinese property file maintained at the server (for some design reasons).

Requirement: I need to maintain the Chinese file at server (utf-8 encoded) without changing server's locale to Chinese. (Similarly, may be later, we may introduce support for some other language. So practically we can't keep server to point to multiple locale simultaneously. Hope I made my point here!)

Problem: I create Chinese property file on windows machine and then FTP it to Solaris machine and try to view it using VI editor. It gets encoded to some default solaris encoding as shown below:

\217\251\300disk-redundancy.mirrors.label=\207\376\251\207\251\226\207\242\346\206\304\272\205\326\277\207\326\251\205\273\362 LoginWindow.login_label=\207\326\251\205\273\362 Id:

P.S. Changing the locale on the server can't be the part of the solution as already explained above.

FYI:LANG= LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_ALL=

Note: 1. cat is showing different result when compared to what described above in VI. Please find below output of cat:

▒▒▒disk-redundancy.mirrors.label=▒▒▒▒▒▒▒▒▒ĺ▒ֿ▒֩▒▒▒ LoginWindow.login_label=▒֩▒▒▒ Id:

I tried to programmatically access file without opening it any editor which, I presume, indicates that the problem is not with the editor.

java DebugTool ?? Id:

  1. Also encoding finder tool on solaris returns UTF-8.

auto_ef -a chinese.properties

UTF-8 1.00

  1. I tried to download this file back to windows and view it in an editor and could successfully view it as Chinese file.

disk-redundancy.mirrors.label=系统监控器登录

disk-redundancy.mirrors.value=登录 Id:

1

The "C" locale only handles ASCII text. You have to use a UTF-8 locale to handle UTF-8 text — you don't need to change the server-wide setting, just the environment variables for the session in which you run the editor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.