Parsing XML in Hebrew language - iphone

I'm using NSXMLParser in iphone app that I'm working on.
Later I'm displaying the text in a view.
All is well when I'm using english language in my XML.
But my XML is in Herbrew language. I'm not able to read the text properly and display it.Please advice me what change do I've to make in XML.

if the XML file is in UTF-8 and you are decoding it using NSUTF8Encoding you should have no problems.
when displaying the strings in UI, remember to set the correct alignment, or the right-to-left will not look correct.

Related

Unity - Displaying Burmese (Zwagyi) text

We're currently developing a game in Unity (2019.4.28f1). This game is played internationally. We'd like to add support for languages other than common Latin written languages. Currently, we're trying to implement support for Burmese, but aren't making much progress.
Finding fonts to display Burmese isn't a big issue. As you can see in the image below, we manage to display all characters that are supposed to be displayed.
However, the big problem here is that the displayed order of symbols isn't the same as what it's supposed to be (see image below for the desired result).
We've tried several fonts that use either Unicode or Zwagyi encoding, but none of them seem to display characters in the correct order. Currently, we're using a padauk font from here, which is supposedly Unicode encoded. Then, within Unity, we applied to following settings to that font:
So, if one of you knows more about this and can share some information with me, that would be much appreciated!
Thanks.
We've already found a solution for this! Before setting the text of the text component convert the Unicode codes to Zwagyi and it'll display the text in the correct order!
All the credits go to this guy who put in the effort to make a tool for these use cases!
Of course, you still need a (Unicode) font that supports these (Burmese) symbols.
Example:
Text textComponent = GetComponent<Text>();
textComponent.text = mmfont.Net.Converter.Uni2ZG(yourUnicodeText);

iTextSharp embeded fonts issue when converting to text

It's obviously very easy to render text from PDF doc using PdfTextExtractor.GetTextFromPage. However when dealing with PDF created with embedded fonts I immediately stumbled into encoding issues.
Is there a generic method that will handle whatever font since i dont have any control on how pdf is created. My task is simple - convert pdf to text.
I've obviously searched for days before posting but could not find answer.
Thank you in advance!
ER

How to parse HTML to PlainText while maintaining paragraph formatting

I have an iOS app that is pulling data from a Restful web service. A portion of the content I am receiving is being loaded into a UITextView. The portion that will be going into the text view is coming in as HTML format. I need to convert it from HTML to plain text while using the paragraph tags to format the text view properly.
Here is what the HTML format looks like
<p data-seq="1"><span class="paragraph">Content of paragraph 1</span></p><p data-seq="2"><span class="paragraph">Content of paragraph 2</span></p>
You can see that <p data-seq="2"><span class="paragraph">....</span></p> designates the start and end of the paragraph.
I initially tried using NSScanner from this example, How to convert NSString HTML markup to plain text NSString?. This was quick to implement but it strips all tags and and parses the text as one long paragraph.
I have added libXml2 to my code. I started following this tutorial for implementation but after I started working through it I wasn't sure how to format the output into paragraphs.
I have also seen recommendations for the DTCoreText library but I didn't see a lot of info on it.
Could someone possibly throw up a snippet using any of the above three options or one of their own on how to parse html into plain text while maintaining the paragraphs?
SOLUTION
Per lxt's recommendation I investigated DTCoreText. Once I managed to get it installed in my app (definitely recommend cocoa pods for that). It was easy as #import "DTCoreText.h" in my detailViewController and then the lines below to add it to the UITextView.
NSDictionary *options = #{DTUseiOS6Attributes: [NSNumber numberWithBool:YES]};
NSData *htmlData = [self.htmlString dataUsingEncoding:NSUTF8StringEncoding];
NSAttributedString *stringArticle = [[NSAttributedString alloc] initWithHTMLData:htmlData options:options documentAttributes:NULL];
self.newsDetailText.attributedText = stringArticle;
The first build failed because I didn't include the DTUseiOS6Attributes line. The second build succeeded and the detail view was perfectly formatted. It was a fist pump moment! Thanks again for the recommendation lxt!
I would honestly recommend using DTCoreText rather than writing your own parser. There's no real benefit reinventing the wheel, and it's also a widely used library with a large user base.
I am surprised you had trouble finding info about it, the library has very good documentation available, and the author is also pretty active on Twitter (#cocoanetics).
You can use the nifty DTAttributedTextView class provided in place of your UITextView. The library also provides a category that extends NSAttributedString with a initWithHTMLData:documentAttributes: method. This will let you create your attributed string and plug it into your view. It's really no more than a couple of lines of code.

Displaying Emojis from Twitter api?

I have an app that retrieves a user's stream and puts it into a UITableView. However, some include emojis (those little smile faces in iOS), and they just return as boxes in my UILabel.
I've done some research, and I still can't figure it out. Does the text type need to be changed?
Thanks!
Please explain your problem better,from the piece that i understood,notice that emojis have native support in iPhone,so any app can display an emoji in a text box,i recommend you to check the methods you're using to add text to the uitableview and the text encoding from the string which is being displayed,also you could check this link
use NSString drawinrect to display emoji instead of drawGlyphsForGlyphRange.

App not displaying 'á' properly in a UILabel

Why does my app draw 'á' as '&aacute' in a UILabel.
I parse the text off a webpage and then draw the text into a label.
Is there something I am missing?
Many Thanks
-Code
This is because the data in the web page is HTML entity encoded so that á is expressed asá. However, as the UILabel doesn't parse/display HTML, it simply displays the content as-is.
As such, you'd need to entity decode the data (to convert á back to á) prior to displaying it. The existing HTML character decoding in Objective-C / Cocoa Touch question/answers (and other questions it links to) should be of some assistance.