I'm using SQLAPI++ to build a backend application which needs to access a database (SQL Server 2014). When I try to read a string (nvarchar(50)) from a result set that contains non-ascii characters (specifically persian characters), the cmd.Field("MyField").asString().GetxxxChars() methods all return question marks (?) instead of those characters.
What should I do?
I have also tried asBytes() and asLongChar() and got the same results.
So I found the problem!
I was linking with sqlapis.lib. I checked this link and found out that I should use sqlapius.lib instead for unicode support. I also needed to define SA_UNICODE.
It is now working fine.
Related
So I am using postgresql in C++ application. I can, without any problems, use german umlaute (Ä,Ö,Ü) in update statements from within PGAdmin or the Windows CMD.
But when I create the same update query in C++ in a char* or std::string and try to execute it with PQexec, it doesn't work and PQexec returns an error value.
Postgresql returns German_Germany.1252 for show lc_collate; and show lc_ctype; and returns UTF8 for server encoding;.
Does someone know what the problem may be?
Edit: Also when I debug the C++ code, Visual Studio shows the query just fine. But when I output it using cout or printf, the umlaut characters are not displayed correctly. I don't know if that's of any relevance.
In DB2 v10 I have a table with following column values:
POST:https:Booking:":getDetails"|26c4ebad-f727-4e59-bcff-3232230ad155|6f9bffbc:85
I need to extract a string between two '|' characters as a new column in a select statement. DB2 does not seem to have built-in regex support. So far I found out regex-like functions can be registered to DB2 using external libraries, but the article is quite old and things might have changed. What is the easiest method to accomplish this? What would be the method with best performance? If I have to add external libraries, is there a good documentation showing how to add and use them with already compiled libraries if possible?
Note:DB2 running on Linux Intel machine.
You might get help from here. Just need to put your string name and pipe character and adjust query according to your needs.
I am recently trying to change our company's old program. One of the huge rocks in my way is that the old program was made with Borland C++, and it had its own way of connecting to the SQL Server 2000 database.
After 8 years, I'm trying to retire this program. But when I looked at the database, I got freaked out!
The whole database was in a vague language that was supposed to be Persian.
I'll give you a portion of the database converted to SQL Server 2005, so you can see it for yourself. I've spent many days trying to figure out how to decode this data. But so far no results has come out of it.
Link to the sample Database File
So please if you can tell me how to use them in Microsoft C#.net it will be much appreciated.
These are the datatypes used for them:
And this is how it looks:
Thanks a lot.
1) Analyse existing program and original database
Try to figure out how the C++ program stored Persian text in the database. What are the collations defined on the original server, database, and on column level.
Does the C++ program convert the data to be stored and retrieved from the database? If so, find out how.
It may well be that the program displays data in Persian, but does not store it in a compatible way. Or it uses a custom font that supports custom encoding. All this needs to be analyzed.
2) The screen shots looks as if everything Persian is encoded as ASCII characters higher than CHAR(128).
If this a standardized encoding or custom created?
3) To migrate the database, you most likely will need to convert the data mapping original characters to Unicode characters.
First recreate the tables using Unicode-enabled columns (NVARCHAR, NVARCHAR(MAX)) rather than CHAR and VARCHAR, which only support Latin or Extended Latin.
4) Even if you successfully migrated your data, SSMS may not correctly display the stored data due to font settings or OS support.
I summarized the difficulties of displaying Unicode in SSMS on my blog.
But first, you need to investigate the original database and application.
During working on one c++ project we decided to use MongoDB database for storing some data of our application. I have spent a week linking and compiling c++ driver, and its works now. But it is one trouble: strings like
bob.append("name", "some text with cyrilic symbols абвгд");
are added incorrectly and after extracting from database look like 4-5 chinese symbols.
I have found no documentation about unicode using in mongodb, so I can not understand how to write unicode to database.
Your example, and the example code in the C++ tutorial on mongodb.org work fine for me on Ubuntu 11.10. My locale is en_US.UTF-8, and I the source files I create are UTF-8.
MongoDB stores data in BSON, and BSON strings are UTF-8, and UTF-8 can handle any Unicode character (including Cyrillic). I think the C++ API assumes strings are UTF-8 encoded, but I'm not sure.
Here are some ideas:
If your code above (bob.append("name"... etc) is in a C++ source code file, try encoding that file as UTF-8.
Try inserting Unicode characters via the mongodb shell.
i've got some weird characters in my database, which seem to mess up django when returning a page. I get this error come up:
TemplateSyntaxError at /search/legacy/
Caught an exception while rendering: Could not decode to UTF-8 column 'maker' with text 'i� G�r'
(the actual text is slightly different, but since it is a company name i've changed it)
how can i get django to output this text? i'm currently running the site from sqlite (fast dev), is this the issue?
Also, on a completely unrelated note, is it possible to use a database view?
thanks
Probably not.
Django is using UTF-8 Strings internally, and it seems that your database returns some invalid string. You should fix the data in the database and use exclusively UTF-8 in all your application (data import, database, templates, source files, ...).
I have a related problem with a site owner who uses Apple's iPages for article creation, then does a copy-paste into a Django admin textbox. This process creates 'funny characters' that screw up Django and/or MySQL (you wouldn't believe the number of different double-left/right quote characters there are). I can't 'fix' the customer so I have a function that looks for known strangeness and translates it to something useful before. A complete PITA.
That's a bit of a confusing error message, and without knowing more details I'm not clear what the source of the problem is (the error message phrasing "decode to UTF-8" seems wrong, as normally you would encode to UTF-8). Perhaps Django is expecting to find data in some other encoding and is trying to decode it and re-encode as UTF-8, but is choking on some characters that aren't valid for the encoding it's expecting?
In general, you want to make sure that you're storing UTF-8 in your database, and that internally you're using unicode objects (not str objects) everywhere in your code.
Some other reading that may be helpful:
Unicode in the real world
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Django Tips: UTF-8, ASCII Encoding Errors, Urllib2, and MySQL