Small patch for handling non-breaking spaces.
Robert Menteer <[email protected]> Tue, 8 Mar 2005 22:03:08 -0500
| Newsgroups | gmane.network.fire.devel |
|---|---|
| Message-ID | <[email protected]> |
Here is a small patch for handling non-breaking spaces.
Index: NSAttributedString+RendezvousHTML.m
===================================================================
RCS file:
/cvsroot/fire/fire/Rendezvous/NSAttributedString+RendezvousHTML.m,v
retrieving revision 1.13
diff -u -d -b -w -u -r1.13 NSAttributedString+RendezvousHTML.m
--- NSAttributedString+RendezvousHTML.m 12 Jan 2005 23:55:47 -0000 1.13
+++ NSAttributedString+RendezvousHTML.m 9 Mar 2005 02:49:59 -0000
@@ -74,9 +74,10 @@
[out replaceCharactersInRange: rng withString: @"'"];
} while (rng.length > 0);
do {
- rng = [out rangeOfString: @" "]; //non breaking space
(don't know how to do the non-breaking part, but got the space easy
+ //non breaking space is a normal character whose glyph looks like a
space
+ rng = [out rangeOfString: @" "];
if (rng.length > 0)
- [out replaceCharactersInRange: rng withString: @" "];
+ [out replaceCharactersInRange: rng withString: @"\xCA"];
} while (rng.length > 0);
//This is a bit more tricky
rng.location = -1;
@@ -453,6 +454,9 @@
case '"':
[escapedstr appendString:@"&quot;"];
break;
+ case '\xCA':
+ [escapedstr appendString:@"&nbsp;"];
+ break;
default:
[escapedstr appendString:
[NSString stringWithCharacters:&aChar length:1]];
@@ -641,6 +645,9 @@
case '"':
[escapedstr appendString:@"""];
break;
+ case '\xCA':
+ [escapedstr appendString:@" "];
+ break;
default:
[escapedstr appendString:
[NSString stringWithCharacters:&aChar
length:1]];
Index: NSAttributedString+AIMLanguage.m
===================================================================
RCS file: /cvsroot/fire/fire/NSAttributedString+AIMLanguage.m,v
retrieving revision 1.54
diff -u -d -b -w -u -r1.54 NSAttributedString+AIMLanguage.m
--- NSAttributedString+AIMLanguage.m 13 Feb 2005 05:18:12 -0000 1.54
+++ NSAttributedString+AIMLanguage.m 9 Mar 2005 02:51:31 -0000
@@ -70,9 +70,10 @@
[out replaceCharactersInRange: rng withString: @"\""];
} while (rng.length > 0);
do {
- rng = [out rangeOfString: @" "]; //non breaking space
(don't know how to do the non-breaking part, but got the space easy
+ //non breaking space is a normal character whose glyph looks like
a space
+ rng = [out rangeOfString: @" "];
if (rng.length > 0)
- [out replaceCharactersInRange: rng withString: @" "];
+ [out replaceCharactersInRange: rng withString: @"\xCA"];
} while (rng.length > 0);
//This is a bit more tricky
rng.location = -1;
@@ -813,6 +814,9 @@
case '&':
[escapedstr appendString:@"&"];
break;
+ case '\xCA':
+ [escapedstr appendString:@" "];
+ break;
default:
[escapedstr appendString:
[NSString stringWithCharacters:&aChar length:1]];
Index: NSStringAdditions.m
===================================================================
RCS file: /cvsroot/fire/fire/NSStringAdditions.m,v
retrieving revision 1.40
diff -u -d -b -w -u -r1.40 NSStringAdditions.m
--- NSStringAdditions.m 31 Dec 2004 20:55:09 -0000 1.40
+++ NSStringAdditions.m 9 Mar 2005 02:52:20 -0000
@@ -101,6 +101,12 @@
if (rng.length > 0)
[out replaceCharactersInRange: rng withString: @"\""];
} while (rng.length > 0);
+ do {
+ //non breaking space is a normal character whose glyph looks like
a space
+ rng = [out rangeOfString: @" "];
+ if (rng.length > 0)
+ [out replaceCharactersInRange: rng withString: @"\xCA"];
+ } while (rng.length > 0);
//This is a bit more tricky
rng.location = -1;
do {
@@ -368,6 +374,9 @@
}else if(character == '"'){
[self replaceCharactersInRange:NSMakeRange(pos, 1)
withString:@"""];
pos += 6;
+ }else if(character == 0x00ca){
+ [self replaceCharactersInRange:NSMakeRange(pos, 1)
withString:@" "];
+ pos += 6;
}else if(character == '\''){
[self replaceCharactersInRange:NSMakeRange(pos, 1)
withString:@"'"];
pos += 6;