Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Base64 decoding and converting to xml

    Hi frnds,

    I am working on a task where I have to convert the Flex application to HTML5.

    I am stuck at the very first step where the Flex application is provided a Base64 encoded string and application converts it to xml. (The Base64 encoded string is XML)

    Following is the code used in Flex
    PHP Code:
    Base64.toXML(unescape("eNrtXMmS28gRvfsraniyDyXWvky0egKrRhGa8XissA8TEx1YCmpYJNEGQG0n/4b/wt/gT")); 
    This is the function in Flex used to convert Base64 encoded string to XML.

    PHP Code:
    toXML(input:Stringuncompress:Boolean true):XML
    {
        var 
    xml:XML;
        var 
    arr:ByteArray Base64.decode(input);
        if(
    uncompressarr.uncompress();
        
    arr.position 0;
        
    xml = new XML(arr.readUTFBytes(arr.length))
        return 
    xml;

    I could find the base64Decode function in JQuery but how should I convert the decoded string to XML. I have been searching all over the net but could not find anything.

    Any help is appreciated.

  • #2
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did some more research

    It seems the xml is converted to ByteArray and then encoded to Base64. I can't change that because it has been developed and maintained by external developer.

    In Flex
    The received string is
    1. unescaped
    2. Base64 decoded
    3. The received byte array is converted to XML.

    Sample of code
    http://codepad.org/6VteCm8F

    I compared the Base64 decoded string in Flex and Javascript and there are few inconsistencies
    http://codepad.org/ekrAdpgH

    The very first problem is Base64 decoding is presenting slightly different results for Flex and Javascript

    I also tried converting the ByteArray to string using the following code in javascript but it is not outputting anything
    http://codepad.org/dKzzffKN



  •  

    Posting Permissions

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