GithubHelp home page GithubHelp logo

2 last characters missing about markdown HOT 9 OPEN

nimbuskit avatar nimbuskit commented on June 29, 2024
2 last characters missing

from markdown.

Comments (9)

oemera avatar oemera commented on June 29, 2024

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

from markdown.

dimitry avatar dimitry commented on June 29, 2024

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

from markdown.

burczyk avatar burczyk commented on June 29, 2024

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

from markdown.

dimitry avatar dimitry commented on June 29, 2024

@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.

from markdown.

burczyk avatar burczyk commented on June 29, 2024

@dimitry yes, something like that. Here you have a few ways to implement it:
http://stackoverflow.com/questions/4191168/how-can-i-count-the-number-of-non-alphanumeric-characters-in-an-nsstring-object

from markdown.

dimitry avatar dimitry commented on June 29, 2024

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

from markdown.

oemera avatar oemera commented on June 29, 2024

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

from markdown.

dimitry avatar dimitry commented on June 29, 2024

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!

from markdown.

AlexDenisov avatar AlexDenisov commented on June 29, 2024

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

from markdown.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.