Cocoa – Trim all leading whitespace from NSString

This creates an NSString category to do what you need. With this, you can call NSString *newString = [mystring stringByTrimmingLeadingWhitespace]; to get a copy minus leading whitespace. (Code is untested, may require some minor debugging.) @interface NSString (trimLeadingWhitespace) -(NSString*)stringByTrimmingLeadingWhitespace; @end @implementation NSString (trimLeadingWhitespace) -(NSString*)stringByTrimmingLeadingWhitespace { NSInteger i = 0; while ((i < [self length]) && … Read more

Emacs Command to Delete Up to Non-Whitespace Character

You might try delete-indentation, my favorite command for joining multiple lines into one line. In your example, put the cursor on the line with “second” and hit M-^ twice. Here are the docs: M-^ runs the command delete-indentation, which is an interactive compiled Lisp function in simple.el. It is bound to M-^. (delete-indentation &optional arg) … Read more

Trim trailing spaces with PostgreSQL

There are many different invisible characters. Many of them have the property WSpace=Y (“whitespace”) in Unicode. But some special characters are not considered “whitespace” and still have no visible representation. The excellent Wikipedia articles about space (punctuation) and whitespace characters should give you an idea. <rant>Unicode sucks in this regard: introducing lots of exotic characters … Read more

git, whitespace errors, squelching and autocrlf, the definitive answers

Squelching is initially a function used in telecommunication to set a threshold above which a signal is or isn’t alllowed through. In your case, when you see: warning: squelched 104 whitespace errors warning: 109 lines add whitespace errors. It means: instead of displaying 100+ error messages, it warns you it should have displayed those errors … Read more

XML Carriage return encoding

To insert a CR into XML, you need to use its character entity &#13;. This is because compliant XML parsers must, before parsing, translate CRLF and any CR not followed by a LF to a single LF. This behavior is defined in the End-of-Line handling section of the XML 1.0 specification.