how to set UTF8 lang on Tomcat/java running on Mac OS 10.5.8?
I'm running Tomcat6 locally on Mac OS 10.5.8. Our staging and production servers have setup an environment variable of:
LANG=en_US.UTF-8
Stage and production run on CentOS and read this value in when java and Tomcat starts up. However, it doesn't appear that java is reading this value and is defaulting to en_US_ISO_85591. On my local machine, I开发者_高级运维 have added LANG=en_US.UTF-8 to my .bash_profile file, because java & Tomcat are running as my user.
If it helps, the situation we're running into is that we have a backend service that delivers xml-formatted UTF8 data to another controller that converts the data into a page-level variable. Its during the conversion process locally that the XML data is being converted to the ISO_85591 format, then back to UTF-8, and it breaks with this error:
Invalid byte 1 of 1-byte UTF-8 sequence.
Is there another way to configure this?
You can set file encoding for tomcat in CATALINA_OPTS environment variable:
cd <tomcat_root>
CATALINA_OPTS="-Dfile.encoding=UTF-8"./bin/startup.sh
精彩评论