Simpatie.ro - matrimoniale
Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Nou pe simpatie:
Alexandra21
Femeie
24 ani
Calarasi
cauta Barbat
24 - 53 ani
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides /

[EXCEL] VBA Function to Convert Character Codes to Representation

Pagini: 1 Moderat de TRaP, TonyTzu
#1
Mrrrr
AdMiN
Postari: 2388
Put in PERSONAL.XLSB then use with =PERSONAL.XLSB!function_name()


Function UTF16encode(ByVal unicode_code_point)
    If (unicode_code_point >= 0 And unicode_code_point <= &HD7FF&) Or (unicode_code_point >= &HE000& And unicode_code_point <= &HFFFF&) Then
        UTF16encode = ChrW(unicode_code_point)
    Else
        unicode_code_point = unicode_code_point - &H10000
        UTF16encode = ChrW(&HD800 Or (unicode_code_point \ &H400&)) & ChrW(&HDC00 Or (unicode_code_point And &H3FF&))
    End If
End Function

Function HTMLdecode(sText)
' REFERENCE: Microsoft VBScript Regular Expression 5.5.
    Dim regEx
    Dim matches
    Dim match
    sText = Replace(sText, "&quot;", Chr(34))
    sText = Replace(sText, "&lt;", Chr(60))
    sText = Replace(sText, "&gt;", Chr(62))
    sText = Replace(sText, "&amp;", Chr(38))
    sText = Replace(sText, "&nbsp;", Chr(32))

    Set regEx = New RegExp

    With regEx
     .Pattern = "&#(\d+);" 'Match html unicode escapes
     .Global = True
    End With

    Set matches = regEx.Execute(sText)

    'Iterate over matches
    For Each match In matches
        'For each unicode match, replace the whole match, with the ChrW of the digits.
        sText = Replace(sText, match.Value, UTF16encode(CLng(match.SubMatches(0))))
    Next

    HTMLdecode = sText
End Function


Either use UTF16encode function:
Eg. =PERSONAL.XLSB!UTF16encode(127757) returns 🌍

Or use HTMLdecode function:
Eg. =PERSONAL.XLSB!HTMLdecode("&#127757;") returns 🌍

Source:
https://stackoverflow.com/a/57161304/21934226

Use with:
https://symbl.cc/en/unicode/table/#misc ... ictographs
https://www.vertex42.com/ExcelTips/unicode-symbols.html
https://emojiguide.org/


_______________________________________


 
   
#2
Mrrrr
AdMiN
Postari: 2388
More conversions in VBA:
https://stackoverflow.com/questions/560 ... r-hex-ffff


_______________________________________


 
   
#3
Mrrrr
AdMiN
Postari: 2388
To find UTF-16 hex codes for VBA, search characters like U+1F643 with:
https://www.fileformat.info/info/unicod ... search.htm

The above U+1F643 converts to 0xD83D 0xDE43 which in VBA translates to ChrW(&HD83D) & ChrW(&HDE43)


Source of fileformat site:
https://stackoverflow.com/questions/560 ... hrough-vba


_______________________________________


 
   
#4
Mrrrr
AdMiN
Postari: 2388
Convert graphical smiley from cell to usable ChrW codes:


Sub Convert_Active_Cell_Smiley()
Dim s
s = ActiveCell
Dim i As Long
For i = 1 To Len(s)
    Dim c
    c = Mid(s, i, 1)
    Debug.Print i, c, AscW(c)
Next i
End Sub


For the following smiley: 🙃
HTML Entity (decimal) encoding: 🙃
Unicode encoding: U+1F643

The above snippet returns:

Code:

1            ?             -10179 
2            ?             -8637

Which can be used in VBA like this: ChrW(-10179) & ChrW(-8637)

Source:
https://stackoverflow.com/a/55418901/21934226


_______________________________________


 
   
Pagini: 1  
Mergi la