aspose file tools*
The moose likes JSP and the fly likes problen about unreadable character when a currency character is expected(CHINESE) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problen about unreadable character when a currency character is expected(CHINESE)" Watch "problen about unreadable character when a currency character is expected(CHINESE)" New topic
Author

problen about unreadable character when a currency character is expected(CHINESE)

Tianpeng Xia
Greenhorn

Joined: Feb 07, 2012
Posts: 16
i have already set: <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> and<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> in the correct place on every page.
and i have also set :response.setCharacterEncoding("UTF-8") and request.setCharacterEncoding("UTF-8") in the code of very servlet.
finally i set Firefox's encoding to "UTF-8".

but still i got no luck

the problem is quite strange because when i directly put a currency symbol to the page, it just worked well. but when i use NumberFormat.getCurrencyInstance(Locale.CHINESE) to get an instance, then used .format(11.29) method to get a String of "¥11.29"(which is expected), i got and unreadable character"¤ ".

please anyone helps with this?
Ram Narayan.M
Ranch Hand

Joined: Jul 11, 2010
Posts: 247

I have not tried this internationalization concept in JSP...

But trying to provide hint...

Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. If the character encoding has already been set by setContentType(java.lang.String) or setLocale(java.util.Locale), this method overrides it. Calling setContentType(java.lang.String) with the String of text/html and calling this method with the String of UTF-8 is equivalent with calling setContentType with the String of text/html; charset=UTF-8.
This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter has been called or after the response has been committed.

Containers must communicate the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the character encoding is communicated as part of the Content-Type header for text media types. Note that the character encoding cannot be communicated via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written via the servlet response's writer.


Please ensure if you are using "setCharacterEncoding()" method before writing the data into OutputStream / reading data from InputStream. Do let us know if fixed, will be useful for us...


SCJP 6 [SCJP - Old is Gold]
Tianpeng Xia
Greenhorn

Joined: Feb 07, 2012
Posts: 16
hi Ram, it seems the problem is solved...
when I set the locale to CHINA from CHINESE, the symbol is correctly displayed. but the FRENCH currency symbole can't by displayed while the UK pound symbol can be displayed if you set the locale to UK...

also, JAPANESE currency symbol has no problem only if you set the locale to JAPAN,not JAPANESE

like this.: NumberFormat currency = NumberFormat.getCurrencyInstance(Locale.JAPAN); return currency.format(a number),

and just now i tried FRANCE instead of FRENCH , then the euro dollor symbol is displayed...

OK THE PROBLEM IS TOTALLY SOLVED... use country names instead of the LANGUAGE NAME...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problen about unreadable character when a currency character is expected(CHINESE)