Is there a way to detect a Unicode alphanumeric character?

I have a Unicode string consisting of letters, numbers and punctuation marks. But can I detect characters that are numbers and letters (not necessarily ASCII) with the standard C ++ library or the Win32 API?

+3
source share
5 answers

iswdigit () , iswalpha () and iswalnum () are the functions you are looking for.

Greetings!

+12
source

Another option is to call the Win32 API GetStringTypeW ()

+5
source

ICU. Unicode, Unicode ++.

+4
source

This Microsoft documentation page describes “Unicode character classes” in regular expressions, which sounds very relevant. I think the answer is in the .Net domain, not in pure Win32 C ++, but maybe you can do something.

+2
source
Private Declare Function GetStringTypeW Lib "Kernel32" (ByVal InfoType As Long, Text As Byte, ByVal Length As Long, Types As Integer) As Long
...
Dim S As String, B() As Byte, C() As Integer, L as Long
L = Len(S)
ReDim C(1 To L)
B = S
If GetStringTypeW(1, B(0), L, C(1)) Then
    'Character classes are in C.
Else
    'Something went wrong. Deal with it or call Err.Raise.
End If
+1
source

Source: https://habr.com/ru/post/1709371/


All Articles