문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top