--- In [email protected], "brucexs" <bswit...@...> wrote: > > I think you need to truncate since note text or can be arbitrarily > long. You also have to scan the string to eliminate invalid file > characters, including those <0x20 and /\* etc. > > But you cannot go just look for those bytes, as they could be the > second byte of a double character, representing something else. > > One way is to scan the bytes, and use Windows built-in function > IsDBCSLeadByte > to know whether to simple copy the next two bytes or whether to check > the current byte. You also use this to truncate once you pass the > maximum. I may try to do a special version just for this since it it > not too hard and I can separate it from the normal code. >
I suggest to use the API _mbsnbcpy in msvcrt.dll in that case. I don't know if this API exists in all versions of Windows, but found it quite handy. One problem is that this API does not null-terminated the copied string, so better initialize the destination buffer with NULLs. Actually I used instead StrCpyN(A) in shell32.dll for that, however, this API seems not documented in MSDN.
