Comments (1)
It looks like you're scanning up to the symbol character set, and then assuming that the symbol part of the scanned string has at least 2 characters:
NSString *word=[read substringWithRange:NSMakeRange(idx, 2)];
I fixed this with the following code:
int charactersToRead = MIN( 2, read.length );
NSString *word=[read substringWithRange:NSMakeRange(idx, charactersToRead)];
But then I found a different bug, where a sentence with a symbol in the middle, like the example above, loses it's space. NSScanners by default have whitespace and newline characters set in charactersToBeSkipped. So in the example string above, after the crash fix, your code scans in "Image ", then "|", then in the second iteration ,the "scanUpToCharactersFromSet" will ignore the " " at the beginning of the remaining string (" Code"). This is all fixed by doing this:
NSScanner *s = [NSScanner scannerWithString:self.text];
[s setCharactersToBeSkipped: nil];
But now, there's a 3rd bug, where it assumes that "words" are separated by spaces. Hence, in a string like this:
@"This is a #test-||-with some symbols."
It is rendered as:
This is a #test- ||-with some symbols.
(Note the extra space between #test- and ||). I don't see an easy way to fix this without re-writing most of this code, so I'll leave it to you. Happy to do a pull request if you care.
from gltaplabeldemo.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gltaplabeldemo.