displaying arabic text

571 views
Skip to first unread message

Asad Ullah

unread,
Nov 19, 2009, 1:17:33 AM11/19/09
to iphonesdkd...@googlegroups.com


Hey ALL

i have  arabic text in sqlite3 and i want to display it in text view, but
i get the display text in this form.

NSlog =data are =?????? ??????? ???????????? ??????????

the NSLog statement is

NSLog(@"\ndata are =%@",[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement,4)]);

does any one has an idea.

JanakiRam Palepu

unread,
Nov 19, 2009, 1:37:25 AM11/19/09
to iphonesdkd...@googlegroups.com
I guess , data could be messed with character encoding...

What is the encoding format of your data stored in SQLite DB. I guess data you had in arabic language conforms to windows-1256
 format.

Thanks
Janakiram


--

You received this message because you are subscribed to the Google Groups "iPhone SDK Development" group.
To post to this group, send email to iphonesdkd...@googlegroups.com.
To unsubscribe from this group, send email to iphonesdkdevelop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/iphonesdkdevelopment?hl=.

Asad Ullah

unread,
Nov 19, 2009, 1:41:43 AM11/19/09
to iphonesdkd...@googlegroups.com
please tell me in which format i should keep arabic text in sqlite db.

thanks

Adham Al-Shehaby

unread,
Nov 19, 2009, 6:30:30 AM11/19/09
to iphonesdkd...@googlegroups.com
it should be in Unicode.

I have been using arabic text with core Data and SQLite with no problems

Adham
Adham El-Shahabi

Asad Ullah

unread,
Nov 19, 2009, 11:24:45 PM11/19/09
to iphonesdkd...@googlegroups.com
salam Adham


Can you explain me further.

i have an arabic sqlite3 db and i want to read it and only display the text.
can you tell me please further that what will be the encoding for sqlite db.
and when i am reading the db i will have to write this statement, but it
does not display the text.



NSLog(@"\ndata are =%@",[NSString stringWithUTF8String:(char *)sqlite3_column_text(
compiledStatement,4)]);


Mike Chen

unread,
Nov 20, 2009, 12:03:28 AM11/20/09
to iphonesdkd...@googlegroups.com
Shouldn't unicode (UTF8) just do well in any language? When you save
your data into your database, you should store it with UTF8 encoding.
And when you read it, you initialize a NSString using encoding UTF8.

Asad Ullah

unread,
Nov 20, 2009, 2:19:14 AM11/20/09
to iphonesdkd...@googlegroups.com
can some one explain me this topic in a little detail.

thanks in advance.

Jesse Tayler

unread,
Nov 20, 2009, 11:08:52 AM11/20/09
to iphonesdkd...@googlegroups.com
advanced unicode handling, even advanced character set handling of any sort is non-trivial, as they say.

the short answer is "no" you can't just store unicode in a UTF or Roman 8 type encoding, unicode takes two bytes per character instead of one, and it changes everything from string search and match to the way data gets stored.

if your database is formatted using unicode, you'll have to read and write using that encoding, any other and it will look like gook.

get the idea there?

David Phillip Oster

unread,
Nov 24, 2009, 5:11:23 PM11/24/09
to iPhone SDK Development
OS X, iPhone and Macintosh have tremendous support for Unicode,
including Arabic. (also the tricky part: mixed Arabic, English, and
punctuation characters.) But, you have to use it correctly.

Store your text in an Arabic-safe encoding. I use UTF-8, which is the
standard for XML. ar.lproj/Localizable.strings are translated to
UTF-16 in the application bundle when you build your app.

NSLog(), because it is writing to the gdb console gets Arabic wrong
becuase gdb is a GNU product, not an Apple product. If you log to a
file, or use NSURLConnection to HTTP POST to a web site you control,
and you specify in your web page that the charset is UTF-8, with a
header on your web page like:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

then you'll be able to see the Arabic correctly. On the iPhone, OS X
version 3.0 and later has support for the Unicode range of Arabic:
\u0600 through \u06FF.

Macintosh adds support for the explicit ligature characters up in FB50
through FDFF and FE70 through FEFF, but those characters are NOT
supported on iPhone.

on iPhone, UITextView, UIWebView and the ordinary text drawing methods
in UIStringDrawing.h will draw Arabic correctly to the screen.

In the simulator, you can use NSString's writeToFile:atomically:
In the debugger, you can even say:
p (BOOL)[myString writeToFile:@"/Users/Shared/temp.txt"
atomically:NO]; and gdb will tell your app to write the string to a
file where you can look at it in Xcode. (Be smart, and set your
default text file format in Xcode and TextEdit to UTF-8.)

Reply all
Reply to author
Forward
0 new messages