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 8045399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:32:04+00:00 2026-06-05T05:32:04+00:00

I get data from a UTF-8 encoded XML file, and I want to display

  • 0

I get data from a UTF-8 encoded XML file, and I want to display every element in a UITableView .
I want my cells to have the same size and display the 2 first text lines with the most data possible so I tried to remove the carriage returns.

In my cellForRow method I changed this :

[[myCell textLabel] setText:data];

By :

[[myCell textLabel] setText:[self correctData:data]];

Here is my correctData method :

- (NSString *) correctData : (NSString *) str
{
    NSMutableString *res = [NSMutableString stringWithFormat:@""];
    for(int i = 0 ; i < [str length] ; i++)
    {
        char car = [str characterAtIndex:i];
        if(car != 10 && car != 13) 
           [res appendString:[NSString stringWithFormat:@"%c",car]];
    }
    return res;
}

And this correctly removes the carriage returns, but it also alters the UTF-8 chars. For example, a bit of the initial string (str) :

Diplômé(e) d’Etat

And with this function it becomes :

DiplÙmÈ(e) d’Etat

What should I do ? Thanks.

  • 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-05T05:32:06+00:00Added an answer on June 5, 2026 at 5:32 am

    NSString works with unichar characters that are stored on 16bits whereas char is only 8bits long. Converting an unichar to a char will alter all characters with a code point above U+00FF.

    You can solve this issue by replacing char with unichar and %c with %C.

    Edit: But that’s not really efficient. You may better use regular expressions to replace all newline characters in once:

    str = [str stringByReplacingOccurrencesOfString:@"[\r\n]+"
                                         withString:@""
                                            options:NSRegularExpressionSearch
                                               range:NSMakeRange(0, str.length)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get data from a server and want to display it using GWT on
I'm trying to get data from website which is encoded in UTF-8 and insert
I am trying to import data from a utf-8 encoded flat file into SQL
How can I get data from a UTF-8-encoded MySQL database without getting the UnicodeDecodeError?
I want to get data from tables in web pages, which seem to be
How do I get data from a Panel to child items? I have the
I have to get data from Oracle Table in which I have one datefield
How to deal with invalid UTF-8 sequences in data from external file / external
We are importing data from .sql script containing UTF-8 encoded data to MySQL database:
I use the ruby-gem sequel to read utf-8-encoded data from a MSSQL-Server table. The

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.