将Unicode字符(下标/上标)存储到PostgreSQL [英] Storing unicode characters(Subscripts/superscripts) to PostgreSQL
问题描述
有人知道这是怎么做的吗?我已经尝试将特殊字符直接保存到查询中,并将其成功保存到数据库中,然后尝试从应用程序中查看它,然后显示愚蠢的字符.也许有些编码我需要了解...请帮助,我真的需要知道这一点的人. :((
P.S.我使用SharpDevelop作为IDE.带有一些用于数据库连接的dll的文件.
我对PostGres一无所知,但类似的常见问题是目标对象(数据库字段,文本字符串等)已设置为仅容纳ASCII字符.检查您的字段的类型定义,看看它是否可以容纳Unicode字符.
好吧,我终于得到了答案.我想这将有助于解决类似这样的未来问题.
我认为这个问题更像是在PostgreSQL上,但是我使用SharpDevelop,所以我认为它很好...
我没有通过直接在查询中存储字符来存储和获取字符.该查询恰好是一个字符串.我所做的是将包含Unicode字符的字符串行转换为字节数组.将其存储到数据库中,并在检索到它之后,再次将其转换为unicode字符串.就是这样.
hi all, Good day. I have spent months over the net looking for answers on how should I save/retrieve a special character unicode(e.g. "\u20fa") in a string and save it to database(which in my case, it is postgreSQL). I just want my chemical formula string to be saved and viewed from database, like a subscript of 2, of chemical formula of ''water''. I''ve made some codes, but the special character appears as a question mark in the database (like this: ?).
Does anyone know how this is done? Ive tried to save a special character directly to the query, and its successfully saved as is to the database, then I tried to view it from my application, then it shows goofy characters. Maybe there''s some encoding stuff i need to understand... Please help, i really need someone who knows this. :((
P.S. Im using SharpDevelop as IDE. With some dll''s for database connection stuff.
I know nothing about PostGres but a common problem with questions like this is that the destination object (database field, text string etc.) has been set up to hold ASCII characters only. Check the type definition of your field to see if it can hold Unicode characters.
Okay, i finally got the answer. I guess this would help for future questions like this.
I think that this prob is more like on PostgreSQL, but I use SharpDevelop so i think its fine...
I didn''t manage to store and get the characters by directly storing it through the query. This query which happens to be a string. What I did was to convert the line of string which contains the unicode character to byte array. Store it to the database, and upon retrieving it, I convert it again to unicode string. And that''s it.
这篇关于将Unicode字符(下标/上标)存储到PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!