Skip to main content
Inspiring
March 23, 2016
Question

Flash Pro CC2015 > AS 3 >Textfield > convert unicode numbers (U+4integers) to charCode (hexidecimal)

  • March 23, 2016
  • 1 reply
  • 679 views

First, I want to thank these forum moderators and members for your attention to this matter.

I am using Flash Pro to display a foreign language font in a textfield.


I have already created the textfield instance, styling, etc.


I have used Windows Character Map (in accessories) to see the glyphs in this font, where in I have a table of each glyph and its unicode equivalent/QWERTY keyboard character (for example ! is U+0021)

Mytextfield.htmlText = String.fromCharCode(0x023D2A)


QUESTION:

This is not strictly a Flash AS3 technical question, but is related to the above implementation.


How do I change the Unicode that I find for a glyph from the Windows Character Map into its Hexidecimal equivalent for use with the CharCode implementation above?


The reason being that there are some glyphs that I need that are not on the QWERTY keyboard but are in the Character Map, accessible by knowing their unicode number. All that I need to display them would be their hexidecimal equivalent. (Yippee! The code that I found on stackoverflow does work! At least in displaying, though I don't know what character glyph 0x023D2A is supposed to look like. It came out as an Asian glyph using SHebrew font.)


The problem being that I can't Google or search Adobe Forum because I don't have the correct jargon for this "hexidecimal" parameter.

Thank you.


PS As I write this, my heart goes out to the victims in Brussels. May we have world peace soon.


References:


List of Unicode characters - Wikipedia, the free encyclopedia


Unicode and HTML for the Hebrew alphabet - Wikipedia, the free encyclopedia


http://stackoverflow.com/questions/2405618/display-unicode-character-in-actionscript

This topic has been closed for replies.

1 reply

Inspiring
March 23, 2016

Unicode/UTF-8-character table

The above table is related as it converts UTF-8 to binary, octals, perl, or hexidecimal among other things, However, once converted, there's nothing that is exactly like 0x000000 format.

googling "Adobe Flash A3 charcode"  gives: KeyboardEvent - Adobe ActionScript® 3 (AS3 ) API Reference, which isn't helpful.

neither is "Char code list": Character Codes -- HTML Codes, Hexadecimal Codes & HTML Names ❤ ❤, which looks like Wikipedia about unicodes.

At least you can see that I'm asking a question after doing some hard work myself first!

Thanks!

Inspiring
March 27, 2016

I googled "Flash AS3 Unicode" and this link came up:

Unicode in Text Field?

You need the hexadecimal (or decimal) equivalent of your unicode representation..

For example the "U+062C" is a Hex value of a unicode char, and its Hex numeric character reference is equivalent to: ج  (note the semicolon at the end) 

Or you may use its decimal equivalen which is: ج  (again attention: the semicolon at the end)

[Need to convert the Hex 062C to Decimal (is 1580)]

In conclusion: use the approprite prefix to denote Hex (&#x) or Dec (&#) value (the Hex is the default) , add your unicode value (without the "U+") and add also a semicolon (;) at the end.

Example:

Code:

U+062C  => ج  (Unicode Hex)  (Note the semicolon at the end) U+062C  => ج  (Unicode Dec) (Note the semicolon at the end)

Similar: The next represents a capital "A":

Code:

U+0041  => A  (Unicode Hex)  (Capital A) U+0041  => A      (Unicode Dec)  (the same as ASCII 65)  //65 => 4*16+1 (41 Hex)

See this AS example:

Code:

//U+062C  this is equivalent to Hex: ج  // note the semicolon  var Char=""  //Char=String.fromCharCode(1580)  // Unicode Dec: ج  Unicode Hex: ج (U+062C) Char=String.fromCharCode(0x062C) // (as Hex)  var Code="ج".charCodeAt(0)  textBox.htmlText =Code+"  "+Char+"  ج  ج"  //  outputs: 1580  ج  ج  ج

Also maybe this is useful:

How to Convert from Hex to Dec (and vise-versa):

 

PHP Code:

// Convert from Dec to Hex
var Dec:Number=1580
var Hex:String=Dec.toString(16)
trace(Hex) // 062C (in Hex)


// Convert from Hex to Dec
Hex="062C"
Dec=parseInt(Hex,16)
trace(Dec// 1580  (in Dec)