0

My sms gateway save message data in log(MSSQL) in Hex code, like this:

0046003A0062006F006B0040007700650062006D0065006400690061002E0070006C

These are Unicode message (16 bits per characters)

Each 4 characters is AsciiHex representation of a character (in hex):

For example:

“0046” = 46hex = ‘F’
“003A” = 3Ahex = ‘:’

how can I convert this in ColdFusion to other format?

Adam

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by webmedia
0

Unfortunately I don't know how to decode UTF16. If it were a regular UTF8 string - or the values always had 2 leading zeroes - you could decode it like any 2 char hex string. Loop and grab every 4 characters. Use inputBaseN to get the ascii code, and convert it to a character. Problem is that would not work if the first 2 chars were something other than 00. Not much help I know, but it may give you some ideas.

<cfloop from="1" to="#len(theString)#" index="x" step="4">
                <cfset fourChars = mid(theString, x, 4)>
                <cfset theChar = chr( inputBaseN( fourChars, 16))>
                <cfoutput> character at [#x#] = #theChar# </cfoutput>
            </cfloop>
0

Thank you, its working....

It works with the sample string, yes. But it wouldn't work if the leading characters are something other than "00" which is possible w/UTF16

0

I make tests and translate about 4000 short sms messages. Working great. Thx.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.