If you know Chinese, you can visit my site for more detail:
http://www.keakon.cn/bbs/thread-1092-1-1.html

And for the rest, I'll give you a example, hope you can understand it.

BTW, all I talk about is in Python env.

1. Define app.yaml:

- url: .*  # NOTE: you need a wildcard to support multi-byte url
  script: main.py


2. Define a multi-byte url handler (handleMultibyteUrl.py):

from urllib import unquote

def handleMultibyteUrl(func):
  def handler(self, *paths):
    if not paths: # no need to escape
      return func(self)

    newPath = []

    for path in paths: # if got several parameters, we should loop at
it
      unquotedPath = unquote(path)
      try:
        path = unicode(unquotedPath, 'utf8')
      except:
        try:
          path = unicode(unquotedPath, 'gbk')
        except:
          try:
            path = unicode(unquotedPath, 'big5')
          except:
            try:
              path = unicode(unquotedPath, 'shiftjis')
            except:
              try:
                path = unicode(unquotedPath, 'korean')
              except:
                pass
      newPath.append(path)
    return func(self, *newPath)

  return handler


3. Define the url handler (main.py):

# -*- coding: utf-8 -*-

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from handleMultibyteUrl import handleMultibyteUrl

class UrlHandler(webapp.RequestHandler):
  @handleMultibyteUrl  # NOTE: the only thing you need is add this
decorator to your url handler
  def get(self, path):
    self.response.out.write(path)


class UrlHandler2(webapp.RequestHandler):
  @handleMultibyteUrl
  def get(self, path1, path2):
    self.response.out.write(path1 + path2)

application = webapp.WSGIApplication([('/(.*)/(.*)', UrlHandler2), ('/
(.*)', UrlHandler)])

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()


OK, you can try these urls now:
http://localhost:8080/你好
http://localhost:8080/中国/欢迎你
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to