How to display tamil characters into UITextView from .rtf/.doc file

不羁的心 提交于 2019-12-24 13:41:20

问题


This is my .rtf file which i included into resources folder of my Xcode project

Code which i used for displaying contents of .rtf file into UITextView

   NSString *filePath=[[NSBundle mainBundle]pathForResource:@"sample" ofType:@"rtf"];
    NSString *contentString=[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];  
    myTextViewObj.text=contentString;

Output which i got is

If anyone knows how to display tamil characters into UITextView from .rtf / .doc / .plist format files help me to get out of this issue.. Thanks in Advance...


回答1:


How to show tamil characters?, is the explanation for your question.

In iOS 4.1 and above has Tamil fonts. Font name :TamilSangamMN-Bold and TamilSangamMN.

The below code snipet will show the list of available font family and its font names.

for (NSString *family in [UIFont familyNames]) 
{ 
    NSLog(@"%@", family); 
    for (NSString *font in [UIFont fontNamesForFamilyName:family]) 
    { 
        NSLog(@"\t%@", font); 
    } 
}

So, apply font & font family accordingly to UITextView to display tamil.




回答2:


An RTF file is not a text file; it's a markup file. What you're seeing (in the yellow image) is the RTF markup that comes at the start of the RTF file; it has nothing to do with the language the text is in.

If you want to see the text, as in your first image, you have to open it in Microsoft Word or another program that reads RTF files and save it in a Unicode text format, not as an RTF. If you want to use the RTF file as a source, you need to write or find an RTF parser.

In other words, you're not looking at the text, you're looking at the source code. There may be a problem with the Tamil text display too, but in the yellow image I don't think you've even gotten to any text yet; just RTF header markup.



来源:https://stackoverflow.com/questions/10443818/how-to-display-tamil-characters-into-uitextview-from-rtf-doc-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!