4

I am trying to construct search method by accepting some keywords as a GET request.

For exmaple, 'articles/search/computer' will likely search for articles that have keyword computer.

Now, if search term contains some other languages, such as Korean word, the rails app produces the following page.

Internal Server Error


"\x80" on CP949

WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18) at hanun.com:3000

and the server has log as follows

[2011-05-15 19:58:05] ERROR Encoding::InvalidByteSequenceError: "\x80" on CP949

I am in a window 7, with ruby 1.9.2p180, rails 3.0.5. I am using webrick as a development server. How can I resolve this problem so that the rails app will accept non-alphanumeric characters as url string??

This url does works: http://127.0.0.1/articles?search=한국

However, following url does not work: http://127.0.0.1/articles/search/한국

user482594
  • 16,878
  • 21
  • 72
  • 108

2 Answers2

2

Ok, the problem was not from rails, but from OS. In windows, any non-alphabetic characters won't be accepted in url if it came in as a shorthand url in rails app. In linux, it works fine. This only happens to rails.

Note that this problems only occurs in Webrick && windows 7 && rails environment.

user482594
  • 16,878
  • 21
  • 72
  • 108
0

URLS sent through http can only be basic ascii, see http://www.w3schools.com/tags/ref_urlencode.asp or http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html

Essentially, your url becomes: http://127.0.0.1/articles/search/%26%2354620%3B%26%2344397%3B

DGM
  • 26,629
  • 7
  • 58
  • 79
  • Yes, I have developed some apps in PHP that accept such non-ascii strings. And for this case, if non-ascii chracters are passed in as variable values, it works fine. However, it does not work if non-ascii characters are in shortened url. – user482594 May 16 '11 at 02:07