无需更改数据库即可在webapp中显示阿拉伯文字 [英] Arabic text displaying in webapp without db changes

查看:86
本文介绍了无需更改数据库即可在webapp中显示阿拉伯文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户输入阿拉伯文名称和密码时,我应该为该用户检索数据。在Java中,我使用utf-8编码
我应该从数据库中检索阿拉伯文形式的数据。我正在使用的数据库是sql server2005。该列设置为varchar而不是nvarchar。因为该数据库指向生产环境。我无法将列类型更改为nvarchar。有什么办法可以转换????从数据库检索的文本变成阿拉伯文本,而无需更改数据库。
任何人都可以帮忙。

When a user enters arabic name and password I am supposed to retrieve data for that user.In java I am using utf-8 encoding I am supposed to retrieve data in the form of arabic text from the database.The database I am using is sql server 2005. and the column is set as varchar instead of nvarchar.Since the database is pointing to production. I could not change the column type to nvarchar. Is there any way to convert the ???? text retrieved from database into arabic text without making changes to DB. Can anyone help on this.

上衣

推荐答案

首先如何将文本存储在数据库中?从根本上来说,听起来您应该正在更改数据库。如果您将 varchar 与非Unicode排序规则一起使用,则 仅限存储符合该排序规则的文本或者,您必须使用极其不可靠且从根本上来说是错误的转换,这些转换会将文本视为二进制数据。

How were you storing the text in the database in the first place? Fundamentally, it sounds like you should be changing the database. If you're using varchar with a non-Unicode collation, then you're either limited to storing text which fits with that collation or you've got to use horribly unreliable and fundamentally "wrong" conversions which treat text as binary data.

即使对于某些人也可以这样做案例,您可能会发现还有其他案例会完全失败。

Even if it's possible to do this for some cases, you may well find that there will be other cases which simply fail.

与您的数据库管理员交谈,解释该架构从根本上是错误的-为了支持完全Unicode,您需要更改架构。您最终必须要经历此过程,因此同时也可以节省一些讨厌的黑客攻击。

Talk to your database administrators, explaining that the schema is fundamentally wrong - in order to support full Unicode, you require a schema change. You'll have to go through this eventually, so you might as well save yourself nasty hacks in the meantime.

这篇关于无需更改数据库即可在webapp中显示阿拉伯文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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