Archive

Archive for November, 2006

Google datacenter check

November 2nd, 2006 No comments

I’ve written a crude datacenter checker. Unfortunately I cannot host it for everyone as Google would ban my server’s IP, so I’ve packaged up the code so anyone can run it.

http://www.noodles.net.nz/downloads/googlecheck.zip

Categories: Coding Tags:

Double byte and PHP (unicode problems)

November 2nd, 2006 No comments

A while back I ran into a problem with PHP, how can I read in files that have double byte (unicode) characters and display them in a form that any browser can read. Most programming languages don’t handle these characters very well, and end up with non sense instead of passing through the correct text.

This function should be able to strip out any unicode characters from text and return them as html entities (something none of the core PHP functions are able to do).

[php]
function removeuni($content){
preg_match_all(“/[\x{90}-\x{3000}]/u”, $content, $matches);

foreach($matches[0] as $match){
$content = str_replace($match, mb_convert_encoding($match, “HTML-ENTITIES”,”UTF-8″), $content);
}

return $content;
}
[/php]

Categories: Coding Tags: