开发者

Encountering encoding issues on linux box, not Windows

开发者 https://www.devze.com 2022-12-24 06:50 出处:网络
I\'m running into an encoding issue that has stumped me for a few weeks and nothing seems to work. I have a website that works fine on my local machine, but when I push the jsp files to a Linux box fo

I'm running into an encoding issue that has stumped me for a few weeks and nothing seems to work. I have a website that works fine on my local machine, but when I push the jsp files to a Linux box for review, characters that previously rendered fine are now displaying as funky characters.

For some reason, some characters display just fine, but other characters will not encode properly. All text on the page is being read from java .properties files and output to the page using beans.

I've开发者_开发百科 added a meta tag to the page to set encoding, which did nothing. I also added <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> but this did nothing on the linux box and actually made the encoding errors appear on my local windows machine.

Any help would be greatly appreciated.


Check that the method loading the properties is using the character encoding that the property files are actually written in.

Without explicit setting this, the default encoding for the file system is used, and it is ISO-Latin-1 on Windows, and UTF-8 on some Linux distributions.


The following need to play together for character encoding to work properly in Nixes and Nuxes:

  • file system encoding
  • database encoding (does not seem to apply)
  • database connector encoding
  • Java-internal string encoding (UTF-16, if I remember correctly)
  • Java output encoding
  • HTML page encoding

With your page directive, you only addressed the last bullet. In other words, you are instructing the brower to decode the page as UTF-8, but that's not what you are sending.

Take a look at this (admittedly a few years old) paper, chapter 11 in particular.


Also, check the physical files on both machines. I've seen several FTP clients muck up files during transfer. A quick check is to push your file as html instead of jsp. You'll get garbage for all the <% %> sequences, but the other text should show up unchanged. You've also taken the app server out of the equation. If the text is still funky, it's your FTP or WebDAV client trying to "help".


Look at the http headers sent by the server. That is the first place the browser looks for encoding before anything else.

0

精彩评论

暂无评论...
验证码 换一张
取 消