A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: reading 1byte+2byte characters from single xml node

  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    247

    reading 1byte+2byte characters from single xml node

    I have an xml file that contains some text in English then straight after some double-byte text in Japanese in the same node. I'm reading it into Flash using node value. Is there any way I can seperate out the English from the Japanese either in the xml or in AS so that I can place the English in one text field and he Japanese in another?

    If I could just place some kind of marker character in between the two portions, then look out for that in AS and use it to split the text, that would be fine.

    thanks
    mark
    Last edited by aldred; 06-08-2006 at 05:46 AM.

  2. #2
    Senior Member
    Join Date
    Mar 2001
    Posts
    247
    Using String.split and a specific character seems to be working. Any way to have AS distinguish the 1 and 2 byte characters?

    mark

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    show us a snippet of the xml structure, it will be easier to help
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    If you loop through the text you should be able to check the characater codes of each character to see which is the multibyte text,

    Maybe something like this,

    Code:
    var str = "the string with english and japanese text";
    for (var i = 0; i < str.length; ++i) {
        var c = str.charCodeAt(i);
        if (c >= 0x0001 && c <= 0x007F) {
            // this character looks english
        } else {
            // multibyte - might be japanese
        }
    }

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