I have the same issue as here.
I use primefaces 2.2 jsf implementation. I've tried all approaches, but works nothing. Is there another solution?
When I try new String (s.getBytes ("iso-8859-1"), "UTF-8");
,
how can I know input encoding?
I have the same issue as here.
I use primefaces 2.2 jsf implementation. I've tried all approaches, but works nothing. Is there another solution?
When I try new String (s.getBytes ("iso-8859-1"), "UTF-8");
,
how can I know input encoding?
String fileName=new String(event.getFile()
.getFileName()
.getBytes(Charset.defaultCharset()),"UTF-8").toUpperCase(locale);
Input encoding is whatever your server is using as default encoding instead of UTF-8. So it is an application wide setting and thus not dependent on specific HTTP requests/clients. More than often it's just the same as Charset#defaultCharset()
.
As to the concrete problem, note that also PrimeFaces 3.3 currently still struggles with this. See also primefaces fileupload filter with utf8 characters filter where you can find some hints to just hack the PrimeFaces source code itself to fix the bug.
I also encounter this kind of problem when I was developing a japanese website. the text becomes unknown character. After some googling I was able to solve this. here is my solution for this.
<h:form enctype="multipart/form-data;charset=UTF-8">
<p:fileUpload id="image" immediate="true" auto="true" sizeLimit="1048576" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" fileUploadListener="#{uploadController.uploadListener}" mode="advanced" multiple="true"/>
</h:form>
you just have to add multipart/form-data;charset=UTF-8
in the enctype of your form.