A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Unicode in Text Field?

  1. #1
    Member
    Join Date
    Dec 2007
    Posts
    46

    Unicode in Text Field?

    Hello Guys
    How can i set the text of a text field with Unicode Text at runtime.
    http://en.wikipedia.org/wiki/List_of...racters#Arabic
    I want to use Arabic

    In depth Explanation will be appreciated
    Thanks in advance

  2. #2
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi,

    Maybe not exactly what you want, but possibly helps (regarding special chars and multilanguage text on flash textfields):
    http://board.flashkit.com/board/showthread.php?t=768105

    Cheers!

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

  3. #3
    Member
    Join Date
    Dec 2007
    Posts
    46
    Thanks a lot for the reply
    Actually i want to make a Simple Word Processor which will use Arabic Unicode Characters. I know how to detect keycode and change text field. but i dont know how to use unicode characters

    e,g
    whenever i use unicode
    U+062C

    textBox.htmlText = "U+062C";
    it simply shows U+062C but not an arabic character

  4. #4
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi again,

    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) 
    Cheers!

    Kostas
    Last edited by Kostas Zotos; 07-03-2008 at 10:56 PM.
    K. Zotos online portfolio: http://www.in3d.eu

  5. #5
    Member
    Join Date
    Dec 2007
    Posts
    46
    Thanks a lot for your reply
    I use your code snippet, but it doesnt working
    Im sure i did something wrong
    please see my attached file and guide me in this regard
    Thanks again
    Attached Files Attached Files

  6. #6
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi,

    Sorry, I couldn't open the file.. (I use Flash 8)

    Maybe the font you are using doesn't include these characters..

    Try not embed the font or use a devise font and espacially one of the flash "internal" fonts eg: _sans, _serif or _typewriter.. (write the font names in the font list combo box dialog, exactly as shown here)

    You will get no antialising with these fonts however..

    Normally if use the syntax as describe in my previous post you will get the results you want (most probably..)

    Bye!

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

  7. #7
    Member
    Join Date
    Dec 2007
    Posts
    46
    Oh My God
    You are Awesome Buddy
    It works, [I did embed fonts which was wrong]
    Thanks once Again.[]

  8. #8
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Your welcome!

    Bye!

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

  9. #9
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi,

    Just to keep this thread updated..

    An alternative way to represent the unicode characters is also this:
    (escaping the unicode -which by default are in HEX- values with the \u)

    "\u062C"

    Example:
    Code:
    TxtField.htmlText="\u062C"  
    
    trace("\u062C")
    (I am a bit busy with various things so cann't be a frequent visitor/contributor as I would like)

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

  10. #10
    Junior Member
    Join Date
    Dec 2005
    Location
    Egypt
    Posts
    11

    FlarabySWF

    Here's an easy way to solve the bidirectional Arabic in Flash problem (at design time).

    http://www.arabicode.com/en/flaraby/swf/

    Demo version included.

    I hope this helps
    There is no god but Allah
    Shagarah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center