简体   繁体   中英

Handle Excel Special Characters using Java

I have a form that allows users to enter in a long legal text. It is likely that users will copy and paste from an Excel and/or a PDF file. I have run into an issue with Special Characters and I have put

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1" %> 

at the top of my jsp page. However, I'm seeing special characters in the text.

For example, in the Excel file there is the following description:

"...Rentee will pay the Rentor... _ all of the rent by a _ of the month"

The "..." is being translated into … (a with a left-to-right tilde). How can I replace those special characters with "..." as one can see in Excel?

I've run into similar problems with people copy / pasting Microsoft "smart quotes" into forms and wondering why they don't render or store correctly later. I made use of the fairly small and straightforward jasciidamnit library to clean these characters out from any input. Give the library a shot, see if it solves your problem

This is happening because the ellipsis "..." is being copied at a single Unicode character (u+2026 or '…'). You should be setting the pageEncoding to UTF-8 because that is what you are sending.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM