Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9257829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:14:56+00:00 2026-06-18T12:14:56+00:00

I need to save a HTML page in my app, and when characters like

  • 0

I need to save a HTML page in my app, and when characters like “€” are found, the saved file displays them wrong.
I tried several encodings but none solves this, is there any solution?
I have also tried to replace the characters for the HTML name, but it still doesn’t work.
Here’s my code:

 NSString *HTML = [web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('html')[0].innerHTML;"];

    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *filePath = [NSString stringWithFormat:@"%@/%@", [path objectAtIndex:0],@"code.html"];

    int enc_arr[] = {
        NSISOLatin1StringEncoding,      // ESP
        NSUTF8StringEncoding,           // UTF-8
        NSShiftJISStringEncoding,       // Shift_JIS
        NSJapaneseEUCStringEncoding,    // EUC-JP
        NSISO2022JPStringEncoding,      // JIS
        NSASCIIStringEncoding           // ASCII
    };

    NSData *urlData= nil;

    for (int i=0; i<6; i++) {
        urlData = [HTML dataUsingEncoding:enc_arr[i]];
        if (urlData!=nil) {
            break;
        }
    }

    [urlData writeToFile:filePath atomically:YES];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:14:57+00:00Added an answer on June 18, 2026 at 12:14 pm

    Ok I finally did it, it’s not the best way but the only one that worked for me and without using external libraries:

    -(NSString*)escapeHTML:(NSString*)code{
    
        NSMutableArray *maExceptions = [[NSMutableArray alloc] initWithObjects: @"Œ", @"œ", @"Š", @"š", @"Ÿ", @"ƒ", @"‘", @"’", @"‚", @"“", @"”", @"„", @"†", @"‡", @"•", @"…", @"‰", @"€", @"™", nil];
    
        for (int i=0; i<[maExceptions count]; i++) {
            code = [code stringByReplacingOccurrencesOfString:[maExceptions objectAtIndex:i] withString:[NSString stringWithFormat:@"&#x%x;",[[maExceptions objectAtIndex:i] characterAtIndex:0]]];
    
        }
    
        return code;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to save objects - instances of classes - in my app like
Because I need to save a web page as a mht file format for
This is the source of my simple HTML page (save as .html file): <!DOCTYPE
I would like to generate a static html page from a php file and
How can i save html page with silverlight object within? I need to be
.txt file need save in SD-card. Save(n + String.valueOf(key) + .txt); private void Save(String
I need to save some classes and data structures to a file. My first
I need to save all .xml file names in a directory to a vector.
How do I save an HTML page with all styles and images in C#
Is there a way to save the changes like changing the background of HTML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.