Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 charsets on the Server side.
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 15 March 2005 :  00:08:20  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
Ok, I'm having some real problems with this script I'm working on. I'll try to keep it as simple as I can.

I'm doing an authentication script, the complication lies in that the passwords I need to authenticate are stored in the SQL database as binary objects.

I've successfully hunted down several functions that convert binary data to string, so that I can compare with form input.

However, it seems the database is Korean, or something, because the output looks like this when I convert from binary to string form:
5ÀáuÄk´¥ ˆ Oˆw»»

However the password is (originally) in english...

So, is there any way without a component to convert that to normal charset? A couple of the functions had a charset option, I tried 'us-ascii' and 'utf-8' but neither worked.

Any help is appreciated, if more details are needed, here's all the functions I tried below:


Function Stream_BinaryToString(Binary, CharSet)
  Const adTypeText = 2
  Const adTypeBinary = 1
  
  'Create Stream object
  Dim BinaryStream 'As New Stream
  Set BinaryStream = CreateObject("ADODB.Stream")
  
  'Specify stream type - we want To save text/string data.
  BinaryStream.Type = adTypeBinary
  
  'Open the stream And write text/string data To the object
  BinaryStream.Open
  BinaryStream.Write Binary
  
  
  'Change stream type To binary
  BinaryStream.Position = 0
  BinaryStream.Type = adTypeText
  
  'Specify charset For the source text (unicode) data.
  If Len(CharSet) > 0 Then
    BinaryStream.CharSet = CharSet
  Else
    BinaryStream.CharSet = "us-ascii"
  End If
  
  'Open the stream And get binary data from the object
  Stream_BinaryToString = BinaryStream.ReadText
End Function
Function BinToText(varBinData, intDataSizeInBytes)    ' as String
        Const adFldLong = &H00000080
        Const adVarChar = 200
        Set objRS = Server.CreateObject("ADODB.Recordset")

        objRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong
        objRS.Open

        objRS.AddNew
        objRS.Fields("txt").AppendChunk varBinData
        BinToText = objRS("txt").Value

        objRS.Close
        Set objRS = Nothing
End Function
Function BinaryToString(Binary)
  Dim cl1, cl2, cl3, pl1, pl2, pl3
  Dim L
  cl1 = 1
  cl2 = 1
  cl3 = 1
  L = LenB(Binary)
  
  Do While cl1<=L
    pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
    cl1 = cl1 + 1
    cl3 = cl3 + 1
    If cl3>300 Then
      pl2 = pl2 & pl3
      pl3 = ""
      cl3 = 1
      cl2 = cl2 + 1
      If cl2>200 Then
        pl1 = pl1 & pl2
        pl2 = ""
        cl2 = 1
      End If
    End If
  Loop
  BinaryToString = pl1 & pl2 & pl3
End Function

-Stim
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.41 seconds. Powered By: Snitz Forums 2000 Version 3.4.07