I have a problem searching my SQLite database, which contains data written with cyrillic characters. If the key word is also cyrillic, then everything is ok, but if not, then I can`t get the result in my Android application.
Does anyone have an idea how can I implement searching the cyrilic data no matter the charset of the keyword?
Thanks
If you use UTF8 encode, There will be no problem.
Actually not. String comparison works only with ascii characters (sort, upper, lower and like). If you are using non-ascii chars you should install plugin, which is like whole SQLite in size. Proof.
If you are interested in cyrillic symbols, try this link.
If you use UTF8 encode, There will be no problem.
Related
I'm having difficulty fetching "special"/German characters (i.e. "öäüß") from my SQLite database using Android.
I'm using the SQLiteOpenHelper class to access the database and the characters show up as either a space or a rectangle.
I can select the fields in Command Line and they display properly, so I assume that they're stored correctly? However, I've used a number of GUI SQLite clients (SQLite Database Browser, sqliteman, Firefox's SQLite client) and none of them have succeeded in displaying the characters properly, so that seems odd, but the real problem is that they don't show up correctly in my app.
I have tried adding:
System.setProperty("file.encoding", "UTF-8")
and
System.setProperty("file.encoding", "ISO-8859-1")
I'm not entirely sure what this means, but I saw it mentioned in related posts so I'll include it:
SELECT hex('ä'); returns 84 and SELECT typeof(data) returns text.
Thanks very much!
84 is not the correct UTF-8 encoding of ä.
The Windows command prompt does not properly support UTF-8.
If you have entered the data from there, the encoding will be wrong.
Use the .read command to read the data from a UTF-8-encoded file, or enter the data with any of the GUI tools, which handle UTF-8 correctly.
I am trying to save some SMS' in a SQLite database from a remote server using an XML parser. I am using urlencode() on server side (PHP) and URLDecoder.decode() on Android. Some of the special characters are replaced by � in the database.
I searched a lot and found that we need to convert UTF-8 to a GSM 7 bit encoding and some similar posts. Does anyone know how to solve this problem?
EDIT:
Here is an example of SMS which is encoded using urlencode()
I+Am+Da+Witness+2+His+Fearless+Death+I+Am+A+Token+Of+His+Last+Promise+%96+4giveness+I+Am+Da+CROSS+Blessings+On+Good+Friday...
that %96 is not supported by URLDecoder.decode()
Changed the text editor to use utf-8 without BOM and it worked!
While using MyPHP admin, I edit records in mySQL database that then is updated into my Android application.
If I paste data into one of my table fields, I often get "NULL" displaying in my app. If I paste the web service URL into a browser I still get the NULL value for that particular field.
After further experimenting, I noticed that editing some characters, that tend to be non-standard, the NULL is replaced with my data. This characters seem to be apostrophes, dashes, and brackets...etc.
Is there some way to do a mass conversion so all my data will paste into my table without editing special characters?
I have tried pasting into Notepad and other editors with the same result.
I then tried various means to ensure my tables were using utf8 character set. This yielded no data to my app. (the Browser method still worked). I don't remember adding anything to my app that set the charset.
Any ideas?
Thanks!
Hard to judge without sample data, url, etc. But I would say, given that this data will be displayed on a mobile device, that you probably would need to paste your data into something like TextWrangler, or NotePad++ and you will have to do a regular expression find and replace on all of the special characters. When you're finished, you would have to reimport into your database.
Another solution is to filter out the special characters right on the server. You could use the PHP str_replace function to filter out special characters as well.
I hope this helps!
I am working on an Android app that I would like to code in such a way so that the Spanish characters coming from the database are read as equivalent to the English ones. For instance, cafe and café would be identical.
Is there a way to do this?
Do you mean that you want queries to find both "cafe" and "café" when you search for "cafe"? You should be able to use a regular expressions to do this.
If this needs to be done on the fly, you could write a function that parses the request for 'e' and generate the correct regular expression before creating the DB query.
I'm using SQLite database in my android project. I want to store there lots of string containing polish fonts. To manage the database I'm using SQLite Database Browser. The problem is: when I'm importing csv filled with strings to database, my text gets changed from, for example "Wysyłaj własnoręcznie" to "Wysy³aj w³asnorêcznie". Any ideas how to properly convert this kind of characters?
Presumably you are opening an InputStream to some source for the csv text, then wrapping that in an InputStreamReader. You need to specify the proper encoding when creating the InputStreamReader. The default encoding is probably ISO-8869-1 and your text is probably UTF-8. This would explain why characters beyond U_007F are not interpreted correctly.