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 la开发者_JAVA百科nguages, 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/한국
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.
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
精彩评论