Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 last characters missing #6

Open
burczyk opened this issue May 9, 2013 · 9 comments
Open

2 last characters missing #6

burczyk opened this issue May 9, 2013 · 9 comments

Comments

@burczyk
Copy link

burczyk commented May 9, 2013

I cloned repo from @myell0w
4e649d4
and I saw that after parsing markdown utf-8 text 2 last characters are missing.
Does anyone have the same problem?

@oemera
Copy link

oemera commented Aug 13, 2013

I have the same issue with utf-8 characters like 'ü', 'ö' and so on! Is there a way to fix this?

@dimitry
Copy link

dimitry commented Aug 14, 2013

Same issue here. Looks like string length is incorrectly computed when dealing with unicode characters.

@burczyk
Copy link
Author

burczyk commented Aug 14, 2013

I 'hacked' it in my app by counting non-standard characters and adding spaces in the end of string. Not pretty, but worked.

@dimitry
Copy link

dimitry commented Aug 14, 2013

@burczyk I'm completely content to do that at this point :) Project needs to launch. Any code snipped to help me get there as well? Are you just counting how many chars are 128 and above? Thank you.

@burczyk
Copy link
Author

burczyk commented Aug 14, 2013

@dimitry
Copy link

dimitry commented Aug 14, 2013

@burczyk spot on! Thank you for your help. And thank you @myell0w for UTF8 support.

@oemera
Copy link

oemera commented Aug 14, 2013

It would be awesome if you could create a sample repository with your fix so other can use it. Thanks guys!

@dimitry
Copy link

dimitry commented Aug 14, 2013

I used @myell0w's fork and then added blank spaces to the end of the markdown string (before sending it to the parser). Here's a quick copy & paste:

NSString *markdown = @"...."; // Your markdown string

// Count non-standard characters
NSUInteger length = [markdown length];
NSUInteger totalNonStandardCharacters = 0;
for(int i=0; i<length; i++) {
    if ([markdown characterAtIndex:i] > 127) {
        totalNonStandardCharacters++;
    }
}

// Make string with spaces (to pad the original text)
NSMutableString *padding = [[NSMutableString alloc] init];
for(int i=0; i<totalNonStandardCharacters; i++) {
    [padding appendString:@" "];
}

// Add padded spaces to the end of the string
markdown = [NSString stringWithFormat:@"%@%@", markdown, padding];

// Now send it to the parser

I think there's a cleaner way to create an empty string with X number of spaces, but no time for it right now. Quick & dirty!

@AlexDenisov
Copy link

Hi guys, here is a fix for this issue #12.
But I faced with another problem, as described here (#2) non-ASCII characters missed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants