LoginSignup
1
0

More than 1 year has passed since last update.

VBA 分記要素をUTF-16E、HEXに分解(Decode)する関数

Posted at

前々回くらいの関数と合わせて使う

isDiaCriticalMarkが必要。それは以下のリンクを参照のこと。
https://qiita.com/Q11Q/items/d983621915846f18a602
成功すれば返り値は配列となる。
文字数は判定できない。合成された文字を各要素に分解し、コードポイントに変換してHEXにする(UTF-16LE)
これもStackOverFlowの記事を参考にして作成した。
excel - Splitting string by combining character groups - Stack Overflow

Function DiaCriticalMarkDecodeArray(str As String) As Variant
Dim i As Long
Dim strLen As Integer
Dim ar()
Dim unicodeLength As Integer
On Error GoTo Err_Handle
strLen = Len(str)
    Dim unicode() As String
    ReDim unicode(strLen)
    ReDim ar(1 To strLen)
If isDiaCriticalMark(str) = True Then
    unicodeLength = 0
    ' Split str into unicode()
    Dim char As Integer
    For i = 1 To strLen
        ar(i) = Right("0000" & Hex(AscW(Mid(str, i, 1))), 4)
    Next
DiaCriticalMarkDecodeArray = ar()
Exit Function
Else
DiaCriticalMarkDecodeArray = False
Exit Function
End If
Exit Function
Err_Handle:
If Err.Number <> 0 Then
Debug.Print "Err occur on UDF:DiaCriticalMarkDecodeArray", Err.Number, Err.Description
Err.Clear
DiaCriticalMarkDecodeArray = ""
End If
Exit Function
End Function
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0