例 Dim bytText As Byte() = New Byte() {49, 0, 50, 0, 51, 0, 65, 0, 66, 0, 67, 0, 66, 48, 68, 48, 70, 48} Dim bytCheck As Byte() = New Byte() {} Dim strCheck As String = "" strCheck = System.Text.Encoding.GetEncoding("utf-16").GetString(bytText) bytCheck = System.Text.Encoding.GetEncoding("utf-16").GetBytes(strCheck) If bytText.SequenceEqual(bytCheck) = true Then Console.WriteLine("utf-16である") End If
匿名 2021/08/12 (Thu) 05:03:38
おかげで面白い判別方法が見つかりました。
例
Dim bytText As Byte() = New Byte() {49, 0, 50, 0, 51, 0, 65, 0, 66, 0, 67, 0, 66, 48, 68, 48, 70, 48}
Dim bytCheck As Byte() = New Byte() {}
Dim strCheck As String = ""
strCheck = System.Text.Encoding.GetEncoding("utf-16").GetString(bytText)
bytCheck = System.Text.Encoding.GetEncoding("utf-16").GetBytes(strCheck)
If bytText.SequenceEqual(bytCheck) = true Then
Console.WriteLine("utf-16である")
End If