Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

? while printing heart symbol

Sorry for asking a stupid question, We are trying to print heart symbol from database to Java XML file. But the same is getting printed as "?" not sure where am I missing. Have tried the char unicode. As a practice I tried it using in main method. Please find the sample java class.

public static void main(String[] args) {

    String t = "\u2665";
    String myUnicodeSymbol = "\u05D0";
    char hollowHeart = '\u2661';
    String hollowDiamond = "\u2662";
    String spade = "\u2660";
    String club = "\u2663";

    StringBuffer buffer = new StringBuffer("<HEAD>");
    buffer.append("<HEART>").append(hollowHeart).append("</HEART>");
    buffer.append("</HEAD>");
    System.out.println(t);
    System.out.println(buffer.toString());
}

The ouput is:- ? ?

Not sure what am I missing.

like image 949
Kiran Avatar asked Feb 01 '12 17:02

Kiran


People also ask

How do I type a heart symbol?

You can type out a heart symbol instantly on Windows if you know the alt code. For example, holding down Alt + 3 on your keyboard's number pad will produce a simple heart.

What does this mean ♡?

It is commonly used to represent love, support, close bonds, and admiration for things that have some relation to the color white, such as white-colored clothing or animals. Par ailleurs, What does ♡ mean in texting? It means “love” or “I love you” or “You're my best friend, I love you” something like that.

How do you get this emoji ♡?

Heart symbol on Android Most likely, heart text symbol emoji is in your default keyboard key set. On my Galaxy SIII I can get ♡ and ♥ symbols by pressing [123] and then [1/3], and on Galaxy Note 4 with Android 5 can get ♡ via [Sym] and then [1/2].

What does ❦ mean?

❦- Floral Heart, fleuron.


1 Answers

I think it depends on settings of the console where the output lands.

I have compiled and run your code in Eclipse and have seen heart symbol. But if I run the program from standard windows console then I see "?" instead of heart symbol too.

However you need to change standard settings in Eclipse.

Window -> Preferences -> General -> Workspace -> set "Text file encoding" to "Other: UTF-8"
like image 156
ka3ak Avatar answered Nov 03 '22 00:11

ka3ak