I
Iñaki Baz Castillo
Hi, I'm using geo_location Ruby gem which returns to me a hash with the giv=
en=20
IP geolocation.
I use Ruby1.9 and UTF-8 works fine, but in this case, when the "city" has=20
"strange" symbols the the gem gives the string encoded in ASCII-8BIT.
=46or example:
Alarc'n (theorically it should be "Alarc=C3=B3n")
I need to send this string to a server which mandates UTF-8 usage so sendin=
g=20
it as it's fails.
I've tryed to convert the encoding but received an error:
result.encode "UTF-8"
=3D> `encode': "\xF3" from ASCII-8BIT to UTF-8
(Encoding::UndefinedConversionError)
I've also tryed with force_encoding:
result.force_encoding "UTF-8"
and then, the "result" string is converted to UTF-8 (I've checked=20
result.encoding) but it's also not valid for the server and when printing i=
t I=20
see the same as before.
I need all of this just for a simple demo, so it owuld be valid for me just=
to=20
delete the non valid UTF-8 chars from the result string, but I don't know=20
how to do it.
Any help please?
=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
en=20
IP geolocation.
I use Ruby1.9 and UTF-8 works fine, but in this case, when the "city" has=20
"strange" symbols the the gem gives the string encoded in ASCII-8BIT.
=46or example:
Alarc'n (theorically it should be "Alarc=C3=B3n")
I need to send this string to a server which mandates UTF-8 usage so sendin=
g=20
it as it's fails.
I've tryed to convert the encoding but received an error:
result.encode "UTF-8"
=3D> `encode': "\xF3" from ASCII-8BIT to UTF-8
(Encoding::UndefinedConversionError)
I've also tryed with force_encoding:
result.force_encoding "UTF-8"
and then, the "result" string is converted to UTF-8 (I've checked=20
result.encoding) but it's also not valid for the server and when printing i=
t I=20
see the same as before.
I need all of this just for a simple demo, so it owuld be valid for me just=
to=20
delete the non valid UTF-8 chars from the result string, but I don't know=20
how to do it.
Any help please?
=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>