Consulting

Results 1 to 4 of 4

Thread: Special chars to UTF-8

  1. #1

    Special chars to UTF-8

    Hi, I have array with words that contain special characters found in German language
    and I'd like to convert that array to UTF-8 encoded words equivalent.

    Thanks for any advice!

  2. #2
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Hi pulsar777!
    The code found on the Internet, but I don't understand either.
    Sub Test()
    Debug.Print Sp2Utf8("special characters") 'you can input special characters here
    End Sub
    Function Sp2Utf8(szCode As String)
        With CreateObject("MSScriptControl.ScriptControl")
            .Language = "JavaScript"
            .addcode "function decode(str){return escape(str).replace(/%/g,'\\')}"
            Sp2Utf8 = .Eval("decode('" & szCode & "')")
        End With
    End Function

  3. #3
    Thanks man ! Even the regular expressions you posted don't do the trick.
    I found out those inputs to database are iso-8859-2 encoded, but db automatically changes it to utf-8 (coverts special chars to weird symbols)
    And I think that's why it cannot convert those symbols back from db to front-end.

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Use:

    Private Declare Function OemToCharA Lib "user32.dll" (ByVal lpszSrc As String, ByVal lpszDst As String) As Long
    
    Public Function F_ASC_ANS(ByVal Text As String) As String
      OemToCharA Text, Text
      F_ASC_ANS = Text
    End Function
    
    Sub M_snb()
       MsgBox F_ASC_ANS("äëïöüß")
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •