Using gperf on UTF-16 encoded input?
When moving code that uses a gperf-generated hashing function to use UTF-16 for its strings, how would you adapt/call the hashing function? The options I can see are:
- Convert UTF-16 to UTF-8 for the hashing. This should work out-of-the-box, but involves a conversion step I hope to be able to avoid.
- Use the
-c开发者_如何学编程
option to make gperf usestrncmp
and encode the input file accordingly, writing\000h\000e\000l\000l\000o
forhello
. I didn't actually test this and would prefer to keep the input file readable and grep-able. But I guess the transformation step could be done with a preprocessing script from the actual source file.
精彩评论