Question

I have a language file in excel.It has a set of arabic strings. When I copy the strings to xcode they are copied in reverse.I see reverse strings.How do I get rid of this problem.

EDIT: Seems the problem is only with xcode.When I copy the same string from xcode to some other place like google translate or other file ,I get the correct non reversed version.

EDIT2: When I copy the arabic string from xcode to another location it is pasted correctly(not in reverse order).So this would mean it would'nt have problems during string processing?

Was it helpful?

Solution

Your string is in Arabic language which starts from RIGHT TO LEFT,and in xcode it is reading the characters of string from LEFT TO RIGHT ( as per english language)

while reading the arabic string compiler will read the character from left to right so therefore it will get the last character of arabic string at very fist and first character of arabic string in last.

you can understand it from Link

OTHER TIPS

This is the way to reverse the string and store in another string

NSString * s = @"تجريب";
unichar *cc = (unichar*)malloc(s.length+1);
[s getCharacters:cc];
for (NSUInteger i=0 ; i < s.length/2 ; i++) {
// swap elements at i and s.length-i-1
unichar tmp = cc[i];
cc[i] = cc[s.length-i-1];
cc[s.length-i-1] = tmp;
}
s = [NSString stringWithCharacters:cc length:s.length];
free(cc);
NSLog(@"%@", s);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top