title: python tornado: encode and decode about url
body: <p>I'm building a web server with tornado. You can search key words and get reply from the server.<br></p>
  
  <p>User can type any word such as Chinese or Japanese, so I know that I should use UTF-8.<br></p>
  
  <p>Here is my core code:<br></p>
  
  <pre><code>class SearchHandler(tornado.web.RequestHandler):
      def get(self, path):
          try:
              print(self.get_argument('key'))
              print(urllib.parse.unquote(self.get_argument('key'))
              val = urllib.parse.unquote(self.get_argument('key'))
              ...
              ...
  </code></pre>
  
  <p>Now let's say that an user searched a Chinese word: 泰国<br>
  The two <code>print</code> will give me the result as below:<br></p>
  
  <pre><code>%E6%B3%B0%E5%9B%BD
  泰国
  </code></pre>
  
  <p>At the backend part, I'll use <code>泰国</code>.<br></p>
  
  <p>For now everything's fine.<br></p>
  
  <p>Today I find some weird words in my log:
  <code>country-cn.html?æ³°å½content</code>
  <a href="https://i.stack.imgur.com/lT8Co.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lT8Co.png" alt="enter image description here"></a></p>
  
  <p>Then I copy it into my browser, it show as it looks like:<br><a href="https://i.stack.imgur.com/GAfHy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GAfHy.png" alt="enter image description here"></a><br></p>
  
  <p>However, I send the log file to a Windows and open it as <code>txt</code>, it shows a Chinese word: 泰国.<br></p>
  
  <p>I'm totally confused now. I use my PC (Mac OS) and type <code>泰国</code> to visit my web server, everything's fine. But it seems that some guy was trying to search the same Chinese word with a special encoding way that I don't know so I couldn't decode it.<br></p>