--- In [email protected], "swzoh" <sean...@...> wrote: > > --- In [email protected], "brucexs" <bswitzer@> wrote: > > OK, ignore d2 and use d3 which I just uploaded and which only checks for a > > single lead byte. > > > I'm asking for curiousity. How you handle it? MSDN strongly recommends using > CharPrev API in the documentation of IsDBCSLeadByte: > "To make sense of a DBCS string, an application normally starts at the > beginning of a string and scans forward, keeping track when it encounters a > lead byte, and treating the next byte as the trailing part of the same > character. If the application must back up, it should use CharPrev instead of > attempting to develop its own algorithm." > > http://msdn.microsoft.com/en-us/library/dd318664.aspx > http://msdn.microsoft.com/en-us/library/ms647471.aspx >
I don't have to back up so its basically a byte by byte scan while (not at end of input and room in output buffer) ---if next input byte is lead byte ------if byte after next input is zero, break loop ------copy lead byte and following byte to output ---else if char>blank and its not a character disallowed in file names ------copy input to output ---else its non ascii or a non-filename so replace by blank in output end There is extra room in output buffer to allow for fact that this may copy two chars at once if last char is dbcs lead.
