[geos-devel] Delocalizing the WKT writer?

sgillies at frii.com sgillies at frii.com
Thu Aug 28 13:00:09 EDT 2008


Chris,

The calls below were added for illustration, they are not in the source
trunk. Sorry about the confusion. I haven't found any other calls to
setlocale.

Sean

> I'm no locale expert, but it looks to me like that is the code that IS
> de-localizing, setting to using the C locale instead of whatever the
> locale is set to in the system? Are there other setlocale calls in the
> writer code itself that undermine this?
>
> Chris
>
> sgillies at frii.com wrote:
>> Can one of the C++ gurus explain why delocalizing the writer (to fix bug
>> 201) isn't as simple as bracing the guts of this function with calls to
>> setlocale()?
>>
>> capi/geos_c.cpp:
>>
>> char*
>> GEOSWKTWriter_write(WKTWriter *writer, const Geometry *geom)
>> {
>>     try
>> 	{
>>                 // switch to C locale
>>                 std::setlocale(LC_ALL, "C");
>> 		std::string s = writer->write(geom);
>>
>> 		char *result;
>> 		result = (char*) std::malloc( s.length() + 1);
>> 		std::strcpy(result, s.c_str() );
>>                 // switch back to native locale
>>                 std::setlocale(LC_ALL, "");
>> 		return result;
>> 	}
>> 	catch (const std::exception &e)
>> 	{
>> 		ERROR_MESSAGE("%s", e.what());
>> 		return NULL;
>> 	}
>>
>> 	catch (...)
>> 	{
>> 		ERROR_MESSAGE("Unknown exception thrown");
>> 		return NULL;
>> 	}
>> }
>>
>> Sure, it would be nice to work this down into the C++ code, but the
>> WKTWriter class is a nightmare.
>>
>> Sean
>>
>> _______________________________________________
>> geos-devel mailing list
>> geos-devel at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/geos-devel
>>
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geos-devel
>




More information about the geos-devel mailing list