Fahim Parkar
Fahim Parkar

Reputation: 31647

Unicode characters (Arabic letters) show up as question marks in IDE console

I am using JSF 2.0 and I have text field as

<h:form>
    <h:inputText value="#{myBean.myValue}" />
    <h:commandButton value="Submit" action="#{myBean.printMe()}" />
</h:form>

public void printMe() {
    System.out.println("first line==" + myValue + "==");
    System.out.println("second line==يشسيبشسيبشسيبشيس==");
}

When I run this project and enter يشسيبشسيبشسيبشيس in textbox, in IDE console I see as below.

INFO: first line==????????????????==
INFO: second line==????????????????==

Any idea why this is happening?

Upvotes: 3

Views: 7047

Answers (2)

BalusC
BalusC

Reputation: 1109645

This is caused by using the wrong console encoding.

The line

System.out.println("My Data is " + fullName);

prints to the standard output (stdout). You need to configure it to use UTF-8 as well. Assuming that you're using Eclipse, then you need to change the stdout encoding to UTF-8 by Window > Preferences > General > Workspace > Text File Encoding.

enter image description here

If you're using Netbeans, which I can't answer from top of head, head to this answer: hebrew appears as question marks in netbeans which contains a link to this Netbeans Wiki which mentions the following:

To change the language encoding for a project:

  1. Right-click a project node in the Projects windows and choose Properties.
  2. Under Sources, select an encoding value from the Encoding drop-down field.

See also:


Unrelated to the concrete problem, those lines in the filter are unnecessary

    res.setCharacterEncoding("UTF-8");
    res.setContentType("text/html;charset=utf-8");

They defaults in case of JSF2/Facelets to proper values already. Remove those lines.

Upvotes: 7

Ragesh Puthiyedath Raju
Ragesh Puthiyedath Raju

Reputation: 3939

If the data comes from a DB, please check the field datatype is nvarchar.

Upvotes: -2

Related Questions