Home » U++ Library support » U++ Core » string filtering bug
string filtering bug [message #22517] |
Tue, 21 July 2009 14:33 |
Zbych
Messages: 327 Registered: July 2009
|
Senior Member |
|
|
Hi,
String filtering functions for some reason treat all input data as bytes. This causes incorrect behaviour of filter if string contains non-ascii letters (ex. polish '±', 'ê') encoded in unicode or utf-8.
WString Filter(const wchar *s, int (*filter)(int))
{
WString result;
while(*s) {
int c = (*filter)((char)*s++);
// ^^^^^^^^^ bug, should be wchar
if(c) result.Cat(c);
}
return result;
}
String Filter(const char *s, int (*filter)(int))
{
String result;
while(*s) {
int c = (*filter)((byte)*s++);
// ^^^^^^^ problem when s is UTF-8
if(c) result.Cat(c);
}
return result;
}
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Wed Jun 05 09:09:37 CEST 2024
Total time taken to generate the page: 0.01224 seconds
|