Le 31/05/2012 21:30, Jean-Michel Caricand a écrit :
> Le 31/05/2012 16:14, Jean-Michel Caricand a écrit :
>> Hello,
>>
>> I have a segfault with this code :
>>
>> #include<iostream>
>> #include<vector>
>> #include<cxxtools/utf8codec.h>
>> #include<cxxtools/jsonserializer.h>
>>
>> int main()
>> {
>> // std::ostringstream o;
>> cxxtools::Utf8Codec codec;
>> // cxxtools::JsonSerializer serializer(o);
>>
>> cxxtools::String s;
>>
>> // s = codec.decode("Advances in Engineering Software");
>> // serializer.serialize(s, "s");
>> s = codec.decode("AI and Society: The Journal of Human-Centred
>> Systems and Machine Intelligence");
>> // serializer.finish();
>>
>> // std::cout<< o.str()<< std::endl;
>>
>> }
>>
>> # g++ rt.cpp -lcxxtools
>> # ./a.out
>> Segmentation fault
>>
>> Any idea ?
>>
>> Thank,
>>
>> Jean-Michel
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Tntnet-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/tntnet-general
> Hello,
>
> Another test :
>
> #include<iostream>
> #include<vector>
> #include<cxxtools/utf8codec.h>
> #include<cxxtools/jsonserializer.h>
>
> int main()
> {
> // std::ostringstream o;
> cxxtools::Utf8Codec codec;
> // cxxtools::JsonSerializer serializer(o);
>
> cxxtools::String s;
>
> s = codec.decode("Advances in Engineering Software");
> std::cout<< "s.size(): "<< s.size()<< std::endl;
> std::cout<< "s.capacity(): "<< s.capacity()<< std::endl;
> std::cout<< s<< std::endl;
>
> s = codec.decode("AI and Society: The Journal of Human-Centred
> Systems and Machine Inte");
> std::cout<< "s.size(): "<< s.size()<< std::endl;
> std::cout<< "s.capacity(): "<< s.capacity()<< std::endl;
> std::cout<< s<< std::endl;
>
> s = codec.decode("AI and Society: The Journal of Human-Centred
> Systems and Machine Intelligence");
> std::cout<< "s.size(): "<< s.size()<< std::endl;
> std::cout<< "s.capacity(): "<< s.capacity()<< std::endl;
> std::cout<< s<< std::endl;
>
> std::cout<< s<< std::endl;
> }
>
>
>
> $ ./a.out
> s.size(): 32
> s.capacity(): 36
> Advances in Engineering Software
> s.size(): 69
> s.capacity(): 81
> AI and Society: The Journal of Human-Centred Systems and Machine Inte
> Erreur de segmentation
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Tntnet-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tntnet-general
The problem is in the decode function :
String Utf8Codec::decode(const char* data, unsigned size)
{
Utf8Codec codec;
//Char to[64];
Char to[512];
MBState state;
String ret;
const char* from = data;
...
But I think Tommi could find a better solution than mine
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general