Suppose you have a Unicode string and you want to do something mathematical with it. You know how to parse DIGIT ZERO “0” through DIGIT NINE “9” but the string may contain Unicode digits like ARABIC-INDIC DIGIT SIX “٦” or DEVANAGARI DIGIT SEVEN “७“, and you want to support those too.
Help here comes from the FoldString
function.
int result = FoldString(MAP_FOLDDIGITS, originalString, -1, resultBuffer, resultBufferSize);
You give the FoldString
function an input buffer, either with an explicit character count, or with -1
to indicate that you want to process up to and including the null terminator. You also give it an output buffer. And you tell it what kind of conversion you want to perform. In our case, we ask for MAP_
FOLDDIGITS
, which means to convert all decimal digits to DIGIT ZERO “0” through DIGIT NINE “9”.
Now you can do your magic mathematical thing with a known number representation.
0 comments