提交到 Web 服务器的希伯来语字符串未收到希伯来语版本
我从我的应用程序向 Web 服务器提交注册表单:
EditText email = (EditText)findViewById(R.id.email);
EditText password = (EditText)findViewById(R.id.password);
EditText nickname = (EditText)findViewById(R.id.nickname);
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("email", email.getText().toString()));
params.add(new BasicNameValuePair("password", password.getText().toString()));
params.add(new BasicNameValuePair("nickname", nickname.getText().toString()));
HttpClient httpClient = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
request.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = httpClient.execute(request);
当我用希伯来语输入昵称时,服务器(php/apache)会以与昵称长度相同的字符串形式接收该昵称,但字符为“不可见”,即看起来像空白。绝对不是希伯来语。有人有任何线索吗?
I submit a sign up form from my app to the web server:
EditText email = (EditText)findViewById(R.id.email);
EditText password = (EditText)findViewById(R.id.password);
EditText nickname = (EditText)findViewById(R.id.nickname);
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("email", email.getText().toString()));
params.add(new BasicNameValuePair("password", password.getText().toString()));
params.add(new BasicNameValuePair("nickname", nickname.getText().toString()));
HttpClient httpClient = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
request.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = httpClient.execute(request);
When I type the nickname in Hebrew, it is received in the server (php/apache) as a string in the same length as the nickname, but with characters which are "invisible", i.e. look like blank spaces. definitely not Hebrew. Any clue someone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为只需执行
request.setEntity(new UrlEncodedFormEntity(params));
即可在 DEFAULT_CONTENT_CHARSET 中对参数进行编码(请参阅 http://developer.android.com/reference/org/apache/http/client/entity/UrlEncodedFormEntity.html)。您可能应该使用
UrlEncodedFormEntity(Listparameters, String encoding)
表单。 Froyo/Android 2.2 添加了对以希伯来语和阿拉伯语(以及其他语言)显示文本的支持,包括所需的字体,但我仍在寻找希伯来语编码字符串...您是否尝试过编码为“UTF-8”或“UTF-” 16英寸?
I think that just doing
request.setEntity(new UrlEncodedFormEntity(params));
encodes your parameters in the DEFAULT_CONTENT_CHARSET (see http://developer.android.com/reference/org/apache/http/client/entity/UrlEncodedFormEntity.html).You should probably use the
UrlEncodedFormEntity(List<? extends NameValuePair> parameters, String encoding)
form. Froyo/Android 2.2 added support for displaying text in Hebrew and Arabic (among other languages), including the needed fonts, but I am still looking for Hebrew encoding string...Have you tried encoding as "UTF-8" or "UTF-16"?