I would like to concatenate the Rupee Symbol Unicode '\u20B9' to a String in java, but I get the following Error, I am using jre7 it has been told in java docs that java7 supports unicode6.0 where this rupee Symbol is added in that version., I have attached my code ant its output below.
public class no {
public static void main(String[] args) {
String rupee = "\u20B9";
JOptionPane.showMessageDialog(null,"Total Amount"+rupee);
}
}
This is not a problem of a string concatenation. It's a problem of the display font. It just doesn't support the character. If I try it on my machine where the standard display fonts have full unicode support, this is the result:
You should try to use a font that has the support, rather than the standard font.
You need a font capable of displaying a glyph for that codepoint. Since the Rupee symbol is relatively new that might be hard. There is no problem with your code here, since you see a square which just means that the font doesn't have a glyph for that character and no suitable other font could be found (assuming that Java does font substitution, I'm not terribly sure of that).
Related
I wouldn't believe I have been stuck on this for one hour, but it seems the fonts for extended unicode characters are not easyly available as TTF / OTF for use on computers, especially with graphic software where unicode fallback doesn't work
especifically I looking for the so called Math bold script
somehting like : 𝓓𝓮𝓶𝓸 𝓯𝓸𝓷𝓽 𝓐𝓑𝓒𝓖𝓟 𝓮𝓻𝓽𝓷𝓭 (<- those are extended chars)
as in https://textfancy.com/font-converter/
as imagen at: https://snipboard.io/fNYd7w.jpg
(becouse I am not sure we all see the same glyphs)
Note: what I am looking for, is a standrd TTF font, which normal glyphs are equal to those extended glyphs, meaning that the A looks like the 𝓐, B like 𝓑, and so on. So I could use the font as normal font in every software.
The STIX math fonts support the Unicode Mathematical Alphanumeric Symbols block.
https://www.stixfonts.org/
https://github.com/stipub/stixfonts
(Note: the variable fonts don't include support for that block of characters; only the static fonts do.)
Please note the intended use of those Unicode characters, as pointed out in the STIX project:
The sans serif, fraktur, script, etc., alphabets in Plane 1 (U+1D400-U+1D4FF) are intended to be used only as technical symbols.
I am replacing my current Text components with TextMeshPro, and when replacing texts containing characters such as superscripts and subscripts, I am getting the error.
I am aware that in TextMeshPro there is the option <sub> </sub> and <sup> </sup> to create superscripts and subscripts, but I preferred to do it directly with characters, as I did with normal Text.
The doubt comes from the fact that some characters are recognized, and others not:
² (recognized)
⁵ (recognized)
⁶ (not recognized)
The subscripts, on the other hand, do not recognize even one of them.
This thread contains all the information on solving the problem.
https://forum.unity.com/threads/textmeshpro-does-not-recognize-subscripts-and-superscripts.1151834/
In short words,
I changed the default font to a font that supported superscripts and subscripts. From that font I created two TMP fonts, one static with the main ASCII characters and one dynamic for the rest of the characters. Then I added the dynamic font in the static font fallbacks, and fine. Add the static font to the TMP and that's it.
I want to use emojis in my iOS and Android app. I checked the list of emojis here and it lists out the hex code for the emojis. When I try to use the hex code such as U+1F600 directly, I don't see the emoji within the app. I found one other way of representing emoji which looks like \uD83D\uDE00. When using this notation, the emoji is seen within the app without any extra code. I think this is a Unicode string for the emoji. I think this is more of a general question that specific to emojis. How can I convert an emoji hex code to the Unicode string as shown above. I didn't find any list where the Unicode for the emojis is listed.
It seems that your question is really one of "how do I display a character, knowing its code point?"
This question turns out to be rather language-dependent! Modern languages have little trouble with this. In Swift, we do this:
$ swift
Welcome to Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1). Type :help for assistance.
1> "\u{1f600}"
$R0: String = "😀"
In JavaScript, it is the same:
$ node
> "\u{1f600}"
'😀'
In Java, you have to do a little more work. If you want to use the code point directly you can say:
new StringBuilder().appendCodePoint(0x1f600).toString();
The sequence "\uD83D\uDE00" also works in all three languages. This is because those "characters" are actually what Unicode calls surrogates and when they are combined together a certain way they stand for a single character. The details of how this all works can be found on the web in many places (look for UTF-16 encoding). The algorithm is there. In a nutshell you take the code point, subtract 10000 hex, and spread out the 20 bits of that difference like this: 110110xxxxxxxxxx110111xxxxxxxxxx.
But rather than worrying about this translation, you should use the code point directly if your language supports it well. You might also be able to copy-paste the emoji character into a good text editor (make sure the encoding is set to UTF-8). If you need to use the surrogates, your best best is to look up a Unicode chart that shows you something called the "UTF-16 encoding."
In Delphi XE #$1F600 is equivalent to #55357#56832 or D83D DE04 smile.
Within a program, I use it in the following way:
const smilepage : array [1..3] of WideString =(#$1F600,#$1F60A,#$2764);
JavaScript - two way
let hex = "😀".codePointAt(0).toString(16)
let emo = String.fromCodePoint("0x"+hex);
console.log(hex, emo);
EDIT: I am no longer asking for a Unicode Library. Not only has one been linked, but the origial question was inappropriate to ask, as mentioned below. This question is now focused on how to implement unicode in XSL-FO.
My primary question now is what steps are required in implementing the unicode. I already have the necessary unicode character references, but I understand that the proper 'font' needs to be selected as well, and am led to believe there are other steps that need to be taken in order to implement it in my XSL-FO document.
What do you mean by "write foreign characters"? An XSL-FO file is just an XML file, so you can use any Unicode reference to figure out the character number and then an XML numeric character reference to include it.
For example, the Unicode hex for the Euro symbol € is U+20ac, so in XML (XSL-FO) that would be €
I experienced a same kind of problem. The problem with unicode characters is hardcoded in the FONET.DLL. In the class TrueTypeFont method MapCharacter is written as:
public override ushort MapCharacter(char c)
{
if (c > Byte.MaxValue)
return (ushort) FirstChar;
return mapping.MapCharacter(c);
}
So any character with a value greater than 255 will be "ignored". I downloaded the sources (from https://fonet.codeplex.com/) and modified the method to:
public override ushort MapCharacter(char c)
{
return mapping.MapCharacter(c);
}
Using this library with this new method, the euro-symbol magically became visible!
I used Netbeans IDE to compile and run the below program.
public class Unicode {
public static void main(String[] args) {
char a=3476;
System.out.println(a);
}
}
But the output was a box. When I ran the program on the console, it printed a question mark. How can I fix the issue?
You can't display a Unicode character on the Windows console directly from Java because it always writes to the console using the application code page (ANSI). However you could use JNA APIs to write unicode characters to the console directly. You would still need to install a monospace font that includes a glyph for the character that you're trying to display.