Posts: 1,058
Threads: 367
Joined: Oct 2007
Hopefully, this is my last enquiry regarding unicode : what about replacing unicode characters in that it concerns the pattern. In the case of ANSI one can use [13] or [32] (instead of space). In unicode how should one search for character 931?
Thanks.
Posts: 11,933
Threads: 138
Joined: Dec 2002
Simply type the character. Why to use character code?
Posts: 1,058
Threads: 367
Joined: Oct 2007
Good question. It is frequently that I receive e-mails with filenames using unicode characters with different code pages. These characters are not recognised as valid file name characters (actually they are displayed as boxes, or in a strange way, ex. "辛匝_ W_ doc"). I want to replace them using str.ReplaceInvalidFilenameCharacters. I know the unicode character codes in my language, I want to exclude others. Thanks.
Posts: 11,933
Threads: 138
Joined: Dec 2002
try this
Macro
str s="辛匝_ W_č doc" ;;UTF8
s.unicode ;;to UTF16
s.ansi(s CP_ACP) ;;to ANSI, using your system ANSI code page. This probably will replace foreign unicode characters to ?.
s.unicode(s CP_ACP)
s.ansi ;;to UTF8
out s
;now ReplaceInvalidFilenameCharacters will replace ? to _
Posts: 11,933
Threads: 138
Joined: Dec 2002
this probably will not be useful in your case
Macro
;creates QM string where a unicode character is as escape sequence
int unicode_character_code=931 ;;change this
BSTR b=" "
b[0]=unicode_character_code
str s=b
int i
str ss
for i 0 s.len
,ss.formata("[%i]" s[i])
out ss
Posts: 1,058
Threads: 367
Joined: Oct 2007