ServletFileUpload encoding issue

2019-09-11 04:05发布

I am using Apache commons fileupload API for uploading a file from UI. In the file there is a entry as given below:

<name>m²</name>

But after loading the file, the character turning into below character

<name>m²</name>

I am not sure if there is something with encoding to do here. Guide please

标签: java encoding
1条回答
走好不送
2楼-- · 2019-09-11 04:42

It appears the uploaded file is XML. In first place the file should be plain text and use entity encoding for superscript 2. Ideally <name>m²</name> should be <name>m&#178;</name>, where is &#178; is the superscript 2 character. The xml processors are supposed to translate this entity character accordingly. The reference to Wikipedia with ISO-8859-1 charset that shows character chart under Codepage layout section.

查看更多
登录 后发表回答