Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

utf-8 to hexadecimal

New Here ,
Jul 23, 2008 Jul 23, 2008
I have a online form which require user to input text (which may contains asian language). the charset of the application is utf-8

How could we convert the received text into their hexadecimal values?

pls kindly advise
675
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 23, 2008 Jul 23, 2008
<cfif structKeyExists(form,"asian_string")>
<cfset strLen = len(form['asian_string'])>
<cfset hex = arrayNew(1)>

<cfloop from="1" to="#strLen#" index="i">
<cfset current_char = mid(form['asian_string'],i,1)>
<cfset arrayAppend(hex,formatBaseN(asc(current_char),16))>
</cfloop>

<cfdump var="#hex#">
</cfif>

<form action="" method="post">
<input type="text" name="asian_string" />
<input type="submit" />
</form>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2008 Jul 23, 2008
Thank you very much.

Pls kindly also advise how to convert hex back to utf8.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 23, 2008 Jul 23, 2008
Hi,

You can try this UDF.

http://cflib.org/udf/hexToString
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 23, 2008 Jul 23, 2008
dynason wrote:
> How could we convert the received text into their hexadecimal values?

why?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2008 Jul 25, 2008
LATEST
I have tried hexToString function but does not display characters correctly.

For example, I used the code from cf.marc to convert an Asian character to hex (value is 4e2d).

After using hexToString, the character is not correctly.

Pls kindly advise.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources