View Single Post
  #1 (permalink)  
Old 08-10-2003
sylvain sylvain is offline
Registered User
 
Name: Sylvain Fasel
Organization: university of Geneva
Project: quantum cryptographic systems
 
Join Date: Feb 2003
Location: Geneva (Switzerland)
Posts: 42
accents problems with Freeze::map

Hi!

I am trying to implement an application using Freeze and I am experiencing problems when working with accentuated characters like "é" or "è".

When inserting a string for a key (or for a value) in a Freeze::map, I can not retrieve this string anymore (the string appears as empty) using Freeze, but the insertion was done in the db, as I can check with db_dump.

I am not sure if this is a problem with Freeze, with Berkeley DB, with my locale settings or something with conflicting utf-8 / iso-8859-15, but anyhow, I cannot make that works. Below I am pasting informations that can be relevant.

I am using linux, kernel version 2.4 (Mandrake 9.1). It seems to me that this Mandrake distribution has troubles with encoding, but I don't know enough about the subject for the moment.

The following code shows the problem:

#include <Freeze/Freeze.h>
#include <StringStringMap.h>
#include <iostream>
int
main(int argc, char* argv[])
{
Ice::CommunicatorPtr communicator=Ice::initialize(argc,argv);
Freeze::DBEnvironmentPtr dbEnv=Freeze::initialize(communicator,"db");
Freeze::DBPtr simpleDB=dbEnv->openDB("simple",true);
StringStringMap Map(simpleDB);

Map.clear();

Map.insert(std::make_pair("yes","elephant"));
Map.insert(std::make_pair("non","élephant"));

for(StringStringMap::const_iterator p=Map.begin();p!=Map.end();++p)
{
std::cout<<p->first<<" "<<p->second<<std::endl;
}

simpleDB->close();
dbEnv->close();
communicator->destroy();
return 0;
}

When running this code, the output is:

non
yes elephant

instead of

non élephant
yes elephant


The command "db_dump -p simple" output:

VERSION=3
format=print
type=btree
db_pagesize=4096
HEADER=END
\0a<Key>non</Key>
\0a<Value>\e9lephant</Value>
\0a<Key>yes</Key>
\0a<Value>elephant</Value>
DATA=END


The "StringStringMap" class was generated with:
slice2freeze --dict StringStringMap,string,string StringStringMap

My c++ compiler is gcc 3.3.

The "locale" command output:

LANG=fr_CH.ISO-8859-15
LC_CTYPE=fr_CH.ISO-8859-15
LC_NUMERIC=fr_CH.ISO-8859-15
LC_TIME=fr_CH.ISO-8859-15
LC_COLLATE=fr_CH.ISO-8859-15
LC_MONETARY=fr_CH.ISO-8859-15
LC_MESSAGES=fr_CH.ISO-8859-15
LC_PAPER=fr_CH.ISO-8859-15
LC_NAME=fr_CH.ISO-8859-15
LC_ADDRESS=fr_CH.ISO-8859-15
LC_TELEPHONE=fr_CH.ISO-8859-15
LC_MEASUREMENT=fr_CH.ISO-8859-15
LC_IDENTIFICATION=fr_CH.ISO-8859-15
LC_ALL=


I hope I give you enough informations.

Thank you in advance for any hint.

Last edited by sylvain : 08-10-2003 at 11:27 AM.
Reply With Quote