解码AppEngine中的国际字符 [英] Decoding international chars in AppEngine

查看:102
本文介绍了解码AppEngine中的国际字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Google AppEngine上做一个小项目,但我遇到了国际版的问题。我的程序通过URLpage.html?data1& data2 ...从用户获取数据并将其存储以供稍后显示。



但是当用户使用一些国际字符如åäö被编码为%F4,%F5和%F6。我认为这是因为只有ASCII表中的前128个字符被允许在http请求中。



有没有人有这个好的解决方案?任何简单的方法来解码文本?在存储数据之前解码它还是更好,或者在向用户显示时解码它。

解析方案

URLs可以包含任何内容,但应该编码。在Java中,您可以使用 URLEncoder URLDecoder 来编码和解码所需的字符编码。



请记住,这些类实际上是用于HTML表单编码,但它们可以应用于URL的查询字符串(参数),因此请勿在整个URL上使用它们 - 仅限参数。


I'm making a small project in Google AppEngine but I'm having problems with international chars. My program takes data from the user through the url "page.html?data1&data2..." and stores it for displaying later.

But when the user are using some international characters like åäö it gets coded as %F4, %F5 and %F6. I assume it is because only the first 128(?) chars in ASCII table are allowed in http-requests.

Is there anyone who has a good solution for this? Any simple way to decode the text? And is it better to decode it before I store the data or should I decode it when displaying it to the user.

解决方案

URLs can contain anything, but it should be encoded. In Java you can use URLEncoder and URLDecoder to encode and decode urls with the desired character encoding.

Have in mind that these classes are actually meant for HTML form encoding, but they can be applied to the query string (the parameters) of the URLs, so do not use them on the whole URLs - only on the parameters.

这篇关于解码AppEngine中的国际字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆