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!
Related
I'm receiving: ������ back from sqlite3 queries, and I'm trying to determine what that means about the underlying data. These characters are supposed to be Cyrillic alphabet characters. These queries are on my desktop.
I am attempting to render them on an Android application, however the values returned from the related queries in the Android application (when viewed in the debugger at-least) are:
\u0003Ȓ\u0001-500-300
In the text view I show them in I see a number of empty squares.
I believe there must be some kind of encoding issue somewhere, but I'm sure how to check and see what actual values are stored in the db, vs what I'm getting back etc...
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 developing a glossary using the sample code Searchable Dictionary. Thanks to searching here, I have figured out how to update the database, which is a .txt file, and then get it to load by changing the version number in Dictionary.java.
My question is, how to do the following:
I would like to be able to insert illustrative images into the definitions.
I would also like to insert links to other entries in the dictionary (e.g. 'inventory' should have a link to 'product flow' and other related terms).
I would also like to know how to insert a carriage return.
My original glossary in spreadsheet format has several fields: 'term' 'definition' 'example' 'related terms'. I want to be able to put in links and images inside these fields and have a couple of carriage returns in between each field to differentiate them.
The dictionary code seems to take in everything as a string, so even if I try to put 'image.jpg', or '\n' for a new line, it simply prints that as part of the string. Is there a way around this?
Searching stackoverflow gave a few links to using SQLite. I am honestly a newbie at all this; the last time I programmed anything significant was ten years ago. Rewriting the code to directly access a SQLite database would be nontrivial for me. So I would like to know if that is really the route I should be taking. If it is, then could you point me to the most simple tutorials for constructing a dictionary that way? I downloaded SQLite data browser, but haven't figured out how to use to construct a new database. I know it should not be so hard; I just don't know what I am doing. :(
If there is an easy way to just do it inline, still using the Searchable Dictionary sample code as a base, that would really make my day. Otherwise, any specific suggestions/directions would be really appreciated.
Thank you!!
Update:
For clarification, below is an example of one entry in my glossary, as desired. There are carriage returns between sections, and links and images are inline with text:
Heijunka, or Load Leveling - An approach to smooth production flow when a mix of products is to be produced, by identifying for a selected time period, the smallest batch size at which to produce each specific product in the mix, before switching over to make another product in the mix.
Example:
Keeping a steady work flow, even if much slower than the original max, reduces waste (<-this is a link to the entry 'waste' in the glossary):
[image of line of balance graph with load leveling, and without]
Related Terms: work structure, demand leveling (<-These are links to respective entries)
Not sure if you saw this already, but Android has some developer lessons for saving Key-Value sets for simple data, and saving to SQLlite for more complex structures.
It sounds like your app needs a database called "Invetory" with the following fields: "ProductImage", "ProductTitle", "ProductLink". And you want to store the image as a BLOB. There's a good SO post on how to take an image from a URL and convert it to a byte array for storage: how to store Image as blob in Sqlite & how to retrieve it?
For the carriage return, i'm assuming you're using "\n"? If that's not working have you tried unescaping your string for TextView:
String s = unescape(stringFromDatabase)
Or for SQLlite:
DatabaseUtils.sqlEscapeString()
Key-value data: http://developer.android.com/training/basics/data-storage/shared-preferences.html
SQLlite data: http://developer.android.com/training/basics/data-storage/databases.html
Additional SQLite resources:
http://www.youtube.com/watch?v=G8ZRXdztESU
http://www.vogella.com/articles/AndroidSQLite/article.html
I've just discovered an issue where city names that contain accent marks, e.g. La Cañada, Peñasco, etc., won't save to my database. Looking through the answers to another SO question, What is the best collation to use for MySQL with PHP?, I've tried changing both my database and the varchar's collation type from latin1_swedish_ci to utf8_general_ci which still refused the character. I also tried utf8_unicode_ci with a similar result.
I've verified that the save works if I strip out the accent mark on the client side, but ideally I'd like to keep it in there, since that is the real name of the city (according to google maps apis anyway).
What collation types do you use to support ñ?
Additional info: Using MySQL, phpMyAdmin, and CakePHP with an Android app as the client
Thanks for the suggestions so far. I guess this is turning into a CakePHP question now... I noticed that by default utf8 is not enabled, so I enabled it in my app/config/database.php file. I FTPed the file back to the server and tried it again still without any luck. Do I need to redeploy the application to kick off those db config changes, or is there another area of my application I should check? First time CakePHP user here.
Collation is merely the order in which characters are sorted, which is a necessary step in performing comparisons. It has nothing to do with how data is stored (except insofar as a given collation is specific to some encoding).
Character encoding is the mapping of characters to their binary representation for storage, which determines the supported character set.
However, just because a database/table/column are using a particular character encoding is not the end of the story. You must also consider the encoding used within your application and on its interfaces with other components (such as MySQL).
Whilst it's aimed at PHP, UTF-8 all the way through pretty much covers all of the things you need to consider.
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.