Tuesday, October 13, 2015

Re: Convert UTF-8 to windows-1252 and write into csv in gwt 2.7.0 on tomcat v7

Hi,

Am 13.10.2015 um 08:49 schrieb balyndar1:
> I am facing a problem with converting UTF-8 to windows-1252. I have
> to output symbols like ²,³,°. The customer wants to open the file in
> Excel without importing the file by double clicking.

not sure what you mean be "importing by double clicking". Do you
mean that Excel should open automatically when receiving the
file from the server? I think you need to set the correct
content-type in the response to let this happen.

> The problem right now is, that the application supports Japanese
> symbols, which are displayed perfectly fine in UTF-8 but not in
> windows-1252.

There are no japanese characters in Cp-1252, so this will
never work.

> On the other hand, the ²,³,° symbols are displayed.

The viewer tries to make sense of the binary data, you surely
have seen the effect of UTF-8 data being shown "as is". This
is a similar effect.

> ByteBuffer bb = ByteBuffer.wrap(content.getBytes());

getBytes without a parameter uses the system-charset which
might not be the one you expect for the encoding. This can
coincidantly work on a Linux-system but on a Windows-system
you get corrupted data.

> Another question is, what is the correct encoding for windows-1252,
> I have tried both versions, cp1252 and windows-1252, I cant spot
> a difference in the result.

Both lead to the same Java Charset.


Cheers, Lothar

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment