Jun 29, 2015

PHP strftime

It took me hours to debug why a template return null, only when using Japanese locale.
Finally I found out.
strftime often used to format nicely date in Japanese, but it will easily broken in production.

There is a workaround to solve this:

function ensureUtf8($text) {
    return iconv(mb_detect_encoding(
        $text, mb_detect_order(), true), "UTF-8", $text    
    );
}


function _strftime($format, $time = null) {
    return ensureUtf8(strftime($format, $time));
}

Jun 19, 2015

New tools

https://github.com/Thibaut/devdocs
I often write code while on commuting train. Local documents are very precious to develop locally without Internet connection.
Days before, I often collect manually by downloading HTML versions (mostly from Readthedocs).
devdocs tool provides much more elegant ways to download and search documents.