Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strings are always ASCII-8BIT... #18

Closed
ramsees opened this issue Feb 13, 2012 · 2 comments
Closed

Strings are always ASCII-8BIT... #18

ramsees opened this issue Feb 13, 2012 · 2 comments

Comments

@ramsees
Copy link

ramsees commented Feb 13, 2012

The adapter ignores the default charset, if I use utf8 It should return UTF-8 encoded strings, but It always returns ASCII-8BIT strings.

This is a problem concatenating strings in Ruby, becase UTF-8 and ASCII-8BIT are not compatible, for example this causes an error if the string containts any of the characters á é í ó ú.

"Hello" + data["my_string"]

I need to do this

"Hello" + data["my_string"].force_encoding("UTF-8")

Doing this is tedious, specially in Sinatra applications.

@rowland
Copy link
Owner

rowland commented Feb 15, 2012

I didn't tackle character set encodings, because I thought I would need to transliterate based on database and column charsets, but it shouldn't be hard to call force_encoding on all returned strings with the encoding specified at the connection level. Would that be acceptable?

If your data is not valid according to the specified encoding, it would fail later operations like regular expressions.

On Feb 13, 2012, at 2:43 PM, ramsees wrote:

The adapter ignores the default charset, if I use utf8 It should return UTF-8 encoded strings, but It always returns ASCII-8BIT strings.

This is a problem concatenating strings in Ruby, becase UTF-8 and ASCII-8BIT are not compatible, for example this causes an error if the string containts any of the characters á é í ó ú.

"Hello" + data["my_string"]

I need to do this

"Hello" + data["my_string"].force_encoding("UTF-8")

Doing this is tedious, specially in Sinatra applications.


Reply to this email directly or view it on GitHub:
#18

@ramsees
Copy link
Author

ramsees commented Feb 16, 2012

Thanks for the answer, Yeah, it is acceptable and it is something I did with my local gem (modifying fb.c).

@rowland rowland closed this as completed May 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants