Anubhaw Prakash
2009-Feb-23 05:41 UTC
Inserting string with special character in database.
Hi all. I am having trouble in reading string containing special characters from file and storing them in database. For example, for string like ''\x89\xA5\xCFI w...'' it throws error "Incorrect string value". The string should be wrappped in duoble quotes, but i didn''t find any method to do so. If any one has solution please help. I need it very badly. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeffrey L. Taylor
2009-Feb-23 08:44 UTC
Re: Inserting string with special character in database.
Quoting Anubhaw Prakash <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Hi all. > I am having trouble in reading string containing special characters from > file and storing them in database. For example, for string like > ''\x89\xA5\xCFI w...'' > it throws error "Incorrect string value". The string should be wrappped > in duoble quotes, but i didn''t find any method to do so. If any one has > solution please help. I need it very badly.Which database and what character set, e.g. UTF-8, Latin1, ASCII? Rails now defaults to UTF-8, but most databases default to Latin1. Jeffrey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anubhaw Prakash
2009-Feb-23 09:17 UTC
Re: Inserting string with special character in database.
Jeffrey L. Taylor wrote:> Quoting Anubhaw Prakash <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> Hi all. >> I am having trouble in reading string containing special characters from >> file and storing them in database. For example, for string like >> ''\x89\xA5\xCFI w...'' >> it throws error "Incorrect string value". The string should be wrappped >> in duoble quotes, but i didn''t find any method to do so. If any one has >> solution please help. I need it very badly. > > Which database and what character set, e.g. UTF-8, Latin1, ASCII? Rails > now > defaults to UTF-8, but most databases default to Latin1. > > JeffreyDatabase is MySql and character set is UTF-8 default. Anubhaw Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Priya Buvan
2009-Feb-23 10:15 UTC
Re: Inserting string with special character in database.
Anubhaw Prakash wrote:> Hi all. > I am having trouble in reading string containing special characters from > file and storing them in database. For example, for string like > ''\x89\xA5\xCFI w...'' > it throws error "Incorrect string value". The string should be wrappped > in duoble quotes, but i didn''t find any method to do so. If any one has > solution please help. I need it very badly. > Thanks.you can give .to_s to convert into string. a= 123 eg: a.to_s -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeffrey L. Taylor
2009-Feb-23 15:23 UTC
Re: Inserting string with special character in database.
Quoting Anubhaw Prakash <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Jeffrey L. Taylor wrote: > > Quoting Anubhaw Prakash <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: > >> > >> Hi all. > >> I am having trouble in reading string containing special characters from > >> file and storing them in database. For example, for string like > >> ''\x89\xA5\xCFI w...'' > >> it throws error "Incorrect string value". The string should be wrappped > >> in duoble quotes, but i didn''t find any method to do so. If any one has > >> solution please help. I need it very badly. > > > > Which database and what character set, e.g. UTF-8, Latin1, ASCII? Rails > > now > > defaults to UTF-8, but most databases default to Latin1. > > > > Jeffrey > > Database is MySql and character set is UTF-8 default. > > Anubhaw > Thanks.The first character is a control code in UTF-8, HTJ. I''ve tried assigning and saving the above character strings in the Rails console. The saved and retrieved string is empty, but I''m not seeing the error "Incorrect string value". What is throwing this error? I also don''t understand the part about wrapping in double quotes. Why can''t you modify your program to change single to double quotes? Jeffrey --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anubhaw Prakash
2009-Feb-24 07:36 UTC
Re: Inserting string with special character in database.
Jeffrey L. Taylor wrote:> Quoting Anubhaw Prakash <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> solution please help. I need it very badly. >> Thanks. > The first character is a control code in UTF-8, HTJ. I''ve tried > assigning and > saving the above character strings in the Rails console. The saved and > retrieved string is empty, but I''m not seeing the error "Incorrect > string > value". What is throwing this error? I also don''t understand the part > about > wrapping in double quotes. Why can''t you modify your program to change > single > to double quotes? > > JeffreyHi Jeffrey, Your question solved my trouble. I set the database character set to Latin1 and it worked. It took the string with special character in DB. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---