How to display wingdings2 symbols in java. I tried googling but i couldn't find much help.
http://www.alanwood.net/demos/wingdings-2.html
Please refer the above link. I would like to display the white diamond symbol.
Wingdings is a font-based trick
The old Wingdings was a hack, a font that used alternate designs as the glyph. For example, where a NUMBER SIGN (pound sign, hash mark) was expected when using character position 35, a fountain pen image appears instead.
For this hack to succeed, (a) the user must have the desired Wingdings font installed, and (b) the text being displayed must use that font specifically.
Unicode
Nowadays, it likely makes sense to use emoji or other image characters defined among the 143,859 characters in Unicode. Those characters are each assigned a number, a code point, using numbers over the range of about a million.
Perhaps this character would work for you: ◇ Unicode Character 'WHITE DIAMOND' (U+25C7) at decimal code point 9,671.
System.out.println( "◇ = WHITE DIAMOND" ) ;
Your user needs a font, any font, that provides a glyph for that particular character. Modern OSes are skilled at automatically finding and using a secondary font with such a glyph if a displayed text block’s primary font is lacking. Understand that no single font provides a glyph for each and every character in Unicode.
There are likely other diamond-related characters too that a search might expose.
As a Java programmer, you can simply paste your desired character into your source code. Be sure to use UTF-8 as the character encoding of your file.
Related
I have a question regarding displaying a suit symbol (ASCII) (heart, diamond, spade, and club) to the terminal window when running a Java program. I currently use JCreator V3 LE. The JDK I use is 1.8.0_172.
In the past, I used the syntax:
Character.toString((char) 3)
Character.toString((char) 4)
Character.toString((char) 5)
Character.toString((char) 6)
Now, it displays a box with a ? in it, as if the character cannot be found. Is there another way to do this, or has this character been eliminated from the window?
Thanks.
As with all text transfers, your Java program (writer) and terminal (reader) need to be on the same page—"code page" (character encoding), that is. You said ASCII but ASCII doesn't support the characters you want to use. You are probably thinking of CP437 from MS-DOS and Windows. (MS-DOS didn't have an ASCII code page; Windows got one late in life, for the sake of completeness. ASCII is only used is very specialized contexts.)
If you want to take Java's character transcoding out of the equation, you can write bytes to the output stream. Then whatever they mean to the terminal, it will decode them to characters.
// for illustration purposes only; I would not invest in code like this.
System.out.flush();
System.out.write(0x03);
System.out.flush();
To actually see them, the terminal has to have a font that includes the decoded character. A white box or box with question mark indicate that the font doesn't. A question mark or question mark in a black diamond indicate that the bytes don't mean anything in the terminal's character encoding.
To check your terminal's character encoding, go chcp (Windows) or locale (most other OSes).
As #VGR stated in the comments, GUIs are simpler. This is because they avoid the concept of creating a byte stream of text in a particular character encoding and just use the windowing system's facility for drawing text. (This comes at the cost of not being able to pipe the output to another program or redirect it to a file, which is a key feature of CUI programs.)
I'm wondering, I saw that Tengwar, an Elvish language created by Tolkien, has some Unicode values. How could I get them into a JavaFX window or console output? I just get a question mark in the console and a box in the JavaFX window.
I'm just trying to say hello in Elvish. The character I tried to use is Hyarmen. The website says that I'm supposed to use
"\u1xy28"
but that didn't work so I tried
"\E020"
which at least didn't give me an error. Can anyone help?
First, "\u1xy28" is incorrect because it contains 2 non hexa characters xy after a \u prefix.
For the rest, according to the document from the official Unicode Consortium about Special Areas and Format Characters
23.5 Private-Use Characters
Private-use characters are assigned Unicode code points whose interpretation is not specified
by this standard and whose use may be determined by private agreement among cooperating
users. These characters are designated for private use and do not have defined,
interpretable semantics except by private agreement.
...
The primary Private Use Area consists of code points in the range U+E000 to U+F8FF, for
a total of 6,400 private-use characters.
That means that you can decide to use those code points for Tengwar characters, but you cannot hope that a standard font will know how to display them (because they are reserved for private use), and you will have to find a dedicated font.
Near the end of the wikipedia page you linked, you can find a link to a comprehensive list of tengwar fonts
I must say that I have not tested any of them...
I am having some trouble with encoding this string into barcode symbology - Code 128.
Text to encode:
1021448642241082212700794828592311
I am using the universal encoder from idautomation.com:
https://www.bcgen.com/fontencoder/
I get the following output for the encoded text for Code 128:
Í*5LvJ8*r5;ÂoP<[7+.Î
However, in ";Âo" the character between the semi-colon and o (let us call it special A) - is not part of the extended character set used in Code128. (See the Latin Supplements at https://www.fonts2u.com/code-128.font)
Yet the same string shows a valid barcode at
https://www.bcgen.com/linear-barcode-creator.html
How?
If I use the output with the Special A on a webpage with a font face for barcodes, the special A character does not show up as the barcode (and that seems correct since the special A is not part of the character set).
What gives? Please help.
I am using the IDAutomation utility to encode the string to 128c symbology. If you can share code to do the encoding (in Java/Python/C/Perl) that would help too.
There are multiple fonts for Code128 that may use different characters to represent the barcode symbols. Make sure the font and the encoding logic match each other.
I used this one http://www.jtbarton.com/Barcodes/Code128.aspx (there is also sample code how to encode it on the site, but you have to translate it from VB). The font works for all three encodings (A, B and C).
Sorry, this is very late.
When you are dealing with the encoding of code 128, in any subset, it's a good idea to think of that coding in terms of numbers, not characters. At this level, when you have shifts, code-changes, checksums and stuff, intermixed with the data, the whole concept of "character" is lost.
However, this is what is happening:
The semicolon in the output corresponds to "27"
The lowercase o corresponds to "48" and the P to "79"
The "A with Macron" corresponds to your "00" sequence. This is why you should be dealing with numbers, not characters, at this level of encoding.
How would you expect it to show a character with a code of 00 ? That would be a space of NULL, neither of which is particularly visible.
Your software has simply rendered it the best way it can, which is to make the character 'visible' by adding 0x80 to it. If you look at charmap, you will see that code 0x80 is indeed A with macron.
The rest (indeed all) of your encoded string looks correct for a setc-encodation.
Is it possible to determine whether data is in English or Chinese?
This is for example possible using statistical methods. English language has a very distinctive distribution of characters that appear at all, and a very distinctive distribution of what characters appear following another character (that would be called a level-1 model).
If 'e' is the most common symbol, it is very unlikely that the language is not something of European origin.
It may also be possible rather trivially (but maybe not 100% reliably) to do such a distinction by looking at Unicode character values (converting between character sets if necessary). If there are characters with a Unicode value greater than 127, English is somewhat unlikely (note that there are symbols like € though).
If there are many characters with Unicode values in the thousands, east Asian languages become more and more likely, with codes > 65535 being guaranteed to be Chinese.
My idea is to calculate the average position of the characters in the Unicode table. Since Chinese characters are located after ASCII (e.g. after value 127) you could easily determine if the text is English or Chinese.
edit: Basically the same Damon added. >_>
What's the best way to insert statistics symbols in a JLabel's text? For example, the x-bar? I tried assigning the text field the following with no success:
<html>x̄
Html codes will not work in Java. However, you can use the unicode escape in Java Strings.
For example:
JLabel label = new JLabel(new String("\u0304"));
Also, here is a cool website for taking Unicode text and turning it into Java String leterals.
Well, that's completely mal-formed HTML, probably even for Swing (I think you would need the </html> at the end for it to work. But I would try to never go that road if you can help it, as Swing's HTML support has many drawbacks and bugs.
You can probably simply insert the appropriate character directly, either directly in the source code if you're using Unicode or with the appropriate Unicode escape:
"x\u0304"
This should work, actually. But it depends on font support and some fonts are pretty bad in positioning combining characters. But short of drawing it yourself it should be your best option.
You can obtain x̄ in adding \u0304 to x character.
In your case, you must generate following string
"x\u0304"
The character \u0304 alone is only a overscore or overline character. It is a special Diacritic character in UNICODE table. You can use it in combination with other normal character to obtain a composite character.
You can find more information on Diacritics characters at following location //en.wikipedia.org/wiki/Combining_character
You can also use
\u0305 to have a longer bar
\u0307 to have a dot above previous character (speed in mechanic)
\u0308 to have 2 dots above previous character (accelaration in
mechanic)
\u0325 to have a circle above previous character
Example
"[x\u0305]" -> x̄
"[z\u0307]" -> x̅
"[t\u0308]" -> ṫ
"[u\u0309]" -> ü
"[A\u030A]" -> Å
In example, only x overlapped with long bar is not correctly displayed in HTML because Chrome browser has a bug (I think).
If you Paste/Copy correctly displayed character in MS Word, you will see correct display of all these characters.
To type a new overlined character in MS Word, you type the character and immediately after you press Alt & 0 774 where 0774 is the base 10 representation of diacritic overline character.