Home | Unicode Tasks | Multibyte Character Set (MBCS) Tasks
Use the following tips:
while ( rgch[ i ] != '\\' )
i++;
This may index a trail byte, not a lead byte, and thus it may not point to a character.
while ( rgch[ i ] != '\\' )
i += _mbslen( rgch + i );
This correctly indexes to a lead byte, hence to a character. The _mbslen function determines the size of a character (one or two bytes).
See Also The Last Character in a String