Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Unicode converter
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Unicode converter

 Post Reply Post Reply
Author
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Topic: Unicode converter
    Posted: 25 May 2005 at 4:30am
Anyone know where I can find a converter that converts text into two bit unicode?
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post Posted: 25 May 2005 at 11:56am
Any decent text editor will give you that option. e.g. Editplus.

And it's upto 4 bytes Wink - depends on the character.
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 25 May 2005 at 4:16pm
Thanks for your reply!

Looking for a ASP server side solution though, and it has to be 2 bytes.

It's for converting messages into Unicode for european clients.
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2005 at 8:35am
Figured it out if anyone is interested:

<%
Dim strout
Dim intLen

strout = Server.HTMLEncode("ø")
strout = replace(strout,"&","")
strout = replace(strout,";","")
strout = replace(strout,"#","")
strout = hex(strout)

intLen = len(strout)

do until intLen >= 4

strout = "0" & strout
intLen = intLen + 1

loop
%>
<%=strout%>
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2005 at 8:54am
Even better:


<%
Option Explicit

'Function to convert it
Function convertToUnicode(strTheNonUnicodeInput)

    Dim strFinalUnicodeOutput
    Dim intInputLength
    Dim intUnicodeLooper
    Dim strSingleUniChar
    Dim intCharsLen

    'Initialise looper
    intUnicodeLooper = 0

    'Get inputs length
    intInputLength = len(strTheNonUnicodeInput)

    'Loop through each character
    do until intUnicodeLooper >= intInputLength

        'Take the single char
        strSingleUniChar = mid(strTheNonUnicodeInput,intUnicodeLooper+1,1)

        'Encode it
        strSingleUniChar = Server.HTMLEncode(strSingleUniChar)

        'Remove junk if we need to (if = 1 then it might be &,; or #)
        if len(strSingleUniChar) > 1 then
            strSingleUniChar = replace(strSingleUniChar,"&","")
            strSingleUniChar = replace(strSingleUniChar,";","")
            strSingleUniChar = replace(strSingleUniChar,"#","")
        else
            strSingleUniChar = Asc(strSingleUniChar)
        end if

        'Hex it
        strSingleUniChar = hex(strSingleUniChar)

        'Add leading 0's to make it 4 bytes
        intCharsLen = len(strSingleUniChar)
        do until intCharsLen >= 4
            strSingleUniChar = "0" & strSingleUniChar
            intCharsLen = intCharsLen + 1
        loop

        'Add to final output
        strFinalUnicodeOutput = strFinalUnicodeOutput & strSingleUniChar

        'Increment
        intUnicodeLooper = intUnicodeLooper + 1

    Loop

    'Return the unicode
    convertToUnicode = strFinalUnicodeOutput

End function

response.write(convertToUnicode("ød"))
%>

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.