Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » BUG: Serious problem with Core/CharSet
icon4.gif  BUG: Serious problem with Core/CharSet [message #26863] Fri, 04 June 2010 00:22 Go to previous message
kov_serg is currently offline  kov_serg
Messages: 37
Registered: August 2008
Location: Russia
Member
Upp2361/WinXP

Testing code shows "error 128=31"

#include <Core/Core.h>

using namespace Upp;
CONSOLE_APP_MAIN {
	wchar_t w[]={0x0410,0}; // must be converted to 0x80,0 see definition of CHRTAB_CP866
	String r=FromUnicode(w,CHARSET_CP866);
	int rc=r[0]&255;
	Cout()<<((rc==0x80)?"ok ":"error 128=")<<rc<<"\n";
}


CHARSET_CP866 has code 62 but if we use 60 instead 62 it will works.

The bug hides here:

Core\CharSet.cpp:2252
...
byte  ResolveCharset(byte charset)
{
	return charset ? charset : DefaultCharset;
}

inline
static CharSetData& s_cset(byte charset)
{
	return s_map()[ResolveCharset(charset)]; // <<<< why charset code used here instead of real index String("CP866") ???
}

s_map() returns ArrayMap<String, CharSetData>& and shuld be indexed by string "CP866" not by charset code 62. Because it real index is 60.

Look at Core\CharSet.cpp:2206
	int q = s_map().GetCount();

And try to ASSERT(q==systemcharset); and this assert fail almost always.

May be at beginig charset codes was equal to s_map item index, but now this is not true. And this is a problem function FromUnicode works wrong.

[Updated on: Fri, 04 June 2010 00:24]

Report message to a moderator

 
Read Message icon4.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon12.gif
Read Message
Read Message
Previous Topic: String: Add Method ReversFind:
Next Topic: double equals nothing
Goto Forum:
  


Current Time: Sun Apr 28 23:00:14 CEST 2024

Total time taken to generate the page: 0.03205 seconds