How to replace accented characters in a Javascript string

If you are dealing with international user, you will sometimes need to replace unicode characters (éåü) with their ascii counterparts (eau). The easiest way is to use a small library called stringops. It extends the String prototype to give your strings the .noAccents method. For instance, you can do “éåü”.noAccents() and you will get “eau”. […]

PHP preg_match failing for no reason? Blame UTF-16.

Recently, I’ve been trying to replace tabs in a document, and I was surprised when my very simple regex, ‘/\t+/’, couldn’t match two tabs while Sublime Text could easily run the same find/replace without a hitch. It turns out that the document was encoded in UTF-16, which PHP’s preg_* functions doesn’t support. UTF-16 adds a […]

How to force Apache to serve UTF-8 by default in .htaccess

If you want to serve all text files as unicode by default, add the following line to your .htaccess: AddDefaultCharset utf-8 You can also set the encoding on individual file types using AddCharset: AddCharset utf-8 .html .css .js .php