MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-Feb-06 20:59 UTC
Socket Connection to Server and Response is in ISO 8859-1 charset
Hi, in my little rail application I have to communicate with a server and everything works great. Except one issue: The server responses are in ISO 8859-1 charset and it seems that I am not able to convert that to utf-8 correctly, which leads to an exception in my mysql insert statement. (seems that one of our German extra characters) Could please somebody help me and explain how to convert my server response correctly? That s the code I am currently using: Timeout::timeout(2) do @client = TCPSocket.open(server[:name], server[:port]) end # get initial hello from server server_response = @client.gets @client.send(command.get_command(), 0) while ((command.response.nil? || !command.response.complete?) && (response_line = @client.gets())) command.set_response(my_parser.parse_response(response_line, command.retrieve_command?)) end -- Volker --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
MrBanabas-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-Feb-08 20:04 UTC
Re: Socket Connection to Server and Response is in ISO 8859-1 charset
Ok.... do not trust your dos box..... A simple: response_line = Iconv.conv(''utf-8'', ''ISO-8859-1'', response_line) did the trick. On 6 Feb., 21:59, "MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org" <MrBana...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, > > in my little rail application I have to communicate with a server and > everything works great. Except one issue: > The server responses are in ISO 8859-1 charset and it seems that I am > not able to convert that to utf-8 correctly, which leads to an > exception in my mysql insert statement. (seems that one of our German > extra characters) > > Could please somebody help me and explain how to convert my server > response correctly? > > That s the code I am currently using: > Timeout::timeout(2) do > @client = TCPSocket.open(server[:name], server[:port]) > end > # get initial hello from server > server_response = @client.gets > > @client.send(command.get_command(), 0) > while ((command.response.nil? || !command.response.complete?) && > (response_line = @client.gets())) > command.set_response(my_parser.parse_response(response_line, > command.retrieve_command?)) > end > > -- > Volker--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---