Topic
  • 3 replies
  • Latest Post - ‏2012-11-29T22:38:05Z by HermannSW
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic How to obtain the string value of an encoded byte array

‏2012-11-28T07:10:52Z |
I am retrieving a base-64 encoded byte array and need to return its string value. Looking over previous posts, I found that this could be done with hex conversion. Am I on the right path?

Thanks for any help.
Updated on 2012-11-29T22:38:05Z at 2012-11-29T22:38:05Z by HermannSW
  • Daviiid
    Daviiid
    284 Posts

    Re: How to obtain the string value of an encoded byte array

    ‏2012-11-28T08:42:02Z  
    Hello

    You can use dp:decode($yourBase64EncodeString, 'base-64')
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: How to obtain the string value of an encoded byte array

    ‏2012-11-29T18:17:13Z  
    • Daviiid
    • ‏2012-11-28T08:42:02Z
    Hello

    You can use dp:decode($yourBase64EncodeString, 'base-64')
    Hello David,

    It is now working using:
    dp:radix-convert(_,64,16)

    Thanks!
  • HermannSW
    HermannSW
    4657 Posts

    Re: How to obtain the string value of an encoded byte array

    ‏2012-11-29T22:38:05Z  
    Hello David,

    It is now working using:
    dp:radix-convert(_,64,16)

    Thanks!
    Hi Cindy,

    your original question was on how to determine the "string value" of a base64 encoded string.
    David answered that question.

    Your "dp:radix-convert(_, 64, 16)" solution does return the "hexadecimally encoded string".
    If that is what you really want, fine.

    But be aware that you will loose any leading 0x00 bytes by this (radix-convert is a "number" function).
    So if you do not want that, you would need a solution like this:
    substring(dp:radix-convert(concat('8AAA', _),64,16),7)
    

    (it prepends base64('F00000')='8AAA', converts, and then just strips the first 6 prepended characters)

     
    Hermann <myXsltBlog/> <myXsltTweets/>
    Updated on 2014-03-25T02:45:19Z at 2014-03-25T02:45:19Z by iron-man