uitextview - Reading Arabic text from a UTF-8 text file? -


dear all, have strange (stupid) problem when trying read "arabic text" given file. let assume have text file called text.txt encoded utf-8 , looks (arabic text righttoleft):

                                                                 :xxx xxxx xx xxx                                                            .xxx, xxxxxxx xxxxx xxx 

when trying read text.txt in xcode using

uitextview *about; about.textalignment = uitextalignmentright; nsstring *textfilepath = [[nsbundle mainbundle] pathforresource:@"text" oftype:@"txt"]; nsstring *filecontents = [nsstring stringwithcontentsoffile:textfilepath encoding:nsutf8stringencoding error:nil]; about.text = filecontents; nslog(@"the text is: \n %@",about.text); 

which believe right way!!! shows on iphone simulator , on device this:

                                                                 xxx xxxx xx xxx:                                                            xxx, xxxxxxx xxxxx xxx. 

which not right text shown !!!!!!!!!!!!!! heck problem of ":" colon , "." period going on wrong side. had headache of problem have been trying solve long time already. please help!!!

best regards;

i don't think there way automatically force right left layout. however, can make method reverse text. read each character , putting mutable string. quick search came this:

-(nsstring *) reversestring {   nsmutablestring *reversedstr;   int len = [self length];    // auto released string   reversedstr = [nsmutablestring stringwithcapacity:len];         // woefully inefficient...   while (len > 0)     [reversedstr appendstring:          [nsstring stringwithformat:@"%c", [self characteratindex:--len]]];       return reversedstr; } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -