Print Page | Close Window

Unicode converter

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=15218
Printed Date: 31 March 2026 at 6:36pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Unicode converter
Posted By: Gullanian
Subject: Unicode converter
Date Posted: 25 May 2005 at 4:30am
Anyone know where I can find a converter that converts text into two bit unicode?



Replies:
Posted By: Bluefrog
Date 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.


-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music


Posted By: Gullanian
Date 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.


Posted By: Gullanian
Date 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%>


Posted By: Gullanian
Date 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"))
%>




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net