Home » U++ Library support » U++ Core » [FIXED] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
Re: [BUG] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed [message #46595 is a reply to message #46591] |
Mon, 06 June 2016 12:56   |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Yes, there is tow,
a - the first can be avoided by specifying a charset,
a possible solution to this is to test if charset is equal to UTF8 (like others ToUpper functions), and do not call s_cset(charset) in this case.
replace : (in file CharSet.cpp, line ~ 2660)
void ToUpper(char *t, const char *s, int len, byte charset)
{
charset = ResolveCharset(charset);
CharSetData& cs = s_cset(charset);
const char *lim = s + len;
while(s < lim)
*t++ = cs.FromUnicode(UPP::ToUpper(cs.ToUnicode(*s++)));
}
by:
void ToUpper(char *t, const char *s, int len, byte charset)
{
charset = ResolveCharset(charset);
if(charset == CHARSET_UTF8)
{
String u = ToUtf8(ToUpper(FromUtf8(s, len)));
memcpy(t, ~u, len);
return;
}
CharSetData& cs = s_cset(charset);
const char *lim = s + len;
while(s < lim)
*t++ = cs.FromUnicode(UPP::ToUpper(cs.ToUnicode(*s++)));
}
b - here a test case for the second BUG:
the code below produce EXCEPTION_ACCESS_VIOLATION
CONSOLE_APP_MAIN
{
char* s = "abcd";
ToUpper(s, s, 4, CHARSET_WIN1250);
}
but the code below work as expected:
CONSOLE_APP_MAIN
{
char* s = "abcd";
StringBuffer r(4);
ToUpper(r, s, 4, CHARSET_WIN1250);
}
then, the bug can be resolved by replacing : (in file CharSet.cpp, line ~ 2630)
void ToUpper(char *s, int len, byte charset)
{
ToUpper(s, s, len, charset);
}
by
void ToUpper(char *s, int len, byte charset)
{
StringBuffer r(len);
ToUpper(r, s, len, charset);
memcpy(s, r, len);
}
regards
omari.
[Updated on: Mon, 06 June 2016 13:21] Report message to a moderator
|
|
|
 |
|
[FIXED] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
By: omari on Fri, 03 June 2016 13:21
|
 |
|
Re: [BUG] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
By: mirek on Sun, 05 June 2016 18:15
|
 |
|
Re: [BUG] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
By: omari on Mon, 06 June 2016 12:56
|
 |
|
Re: [BUG] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
By: mirek on Thu, 09 June 2016 14:27
|
 |
|
Re: [BUG] ToUpper, ToLower,and ToAscii (char*, int) causes AssertFailed
By: omari on Fri, 10 June 2016 11:56
|
Goto Forum:
Current Time: Sun Aug 24 21:50:21 CEST 2025
Total time taken to generate the page: 0.05752 seconds
|