Month: August 2006

  • UTF-8 substr fot PHP

    “[Pulling] out an arbitrary substring which happens to cut a 2 byte UTF-8 sequence breaks the string;

    <?php
    header ('Content-type: text/html; charset=utf-8');
     
    $haystack = 'Iñtërnâtiônàlizætiøn';
     
    // Position 13 is in the middle of the ô char
    $substr = substr($haystack, 0, 13);
     
    print "Substr: $substr<br>";

    $substr now contains badly formed UTF-8 and your browser should display something wierd as a result (probably a ?)”

    Handling UTF-8 with PHP”
    phpwact.org

    a comment moved due to layout issues

    To go around this limitation, I used the following replacement substr code, which I extracted from “UTF-8 friendly replacement functions” v0.2, by Niels Leenheer & Andy Matsubara. For some reason, at the time of writing this, Google only seems to find a PDF version of this document.

    function substr($str, $start , $length = NULL) {
    
                 preg_match_all('/[\x01-\x7F]|[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF][\x80-\xBF]/', $str, $arr);
    
                 if (is_int($length))
    
                       return implode('', array_slice($arr[0], $start, $length));
    
                 else
    
                       return implode('', array_slice($arr[0], $start));
    
          }
  • Subtitle timings for .srt's with ProjectX

    Afterdawn’s ProjectX guide told me to select re-build TTX-PTS from 1st MpgAudio stream… in the PreSettings, so I did, and voilá! Now I don’t have to time the subtitles manually with VisualSubSync anymore. What a waste of effort that proved to be!

  • Microsoft puts police link on Messenger

    Users of Microsoft’s Messenger email service will be able to report suspected sexual predators directly to the police at the click of a mouse. […] Microsoft will add a report abuse icon to Messenger that will link any users worried about their anonymous internet buddies directly to online police services.

    Guardian via BlogsNow

  • freenigma

    Freenigma promises to provide encryption for major webmail services such as GMail, Yahoo! Mail and Hotmail, using a simple to set-up Firefox extension. (Via Killinki)

  • IE7 on viimeistä silausta vaille valmis

    Microsoft julkisti tiistaina Internet Explorer 7 -selaimesta Release Candidate 1 -version, jonka pitäisi vastata ominaisuuksiltaan kuluvan vuoden aikana markkinoille tulevaa, lopullista tuotantoversiota. RC1-versio on vapaasti halukkaiden saatavilla Microsoftin sivujen tai automaattisen päivityspalvelun kautta.

    Tietoviikko

    IE:n suomenkielisillä sivuilla ollaan tämän kirjoitushetkellä vielä versiossa Beta 3, eikä RC1 ole myöskään tarjolla Windows Updaten valinnaisten päivitysten joukossa. Microsoft.comin IE-sivustolta se siis kuitenkin jo löytyy, mitä ilmeisimmin englanninkielisenä. En ole koeasentanut sitä, odotan suomenkielistä versiota.

  • Apple Recalls iBook, PowerBook Batteries Due To Fire Hazard

    Name of Product: Rechargeable, lithium-ion batteries with cells manufactured by Sony for certain previous iBook G4 and PowerBook G4 notebook computers only.

    Units: About 1.1 million battery packs (an additional 700,000 battery packs were sold outside the U.S.)

    Battery Cell Manufacturer: Sony Energy Devices Corp., of Japan

    Computer Manufacturer: Apple Computer Inc., of Cupertino, Calif.

    Hazard: These lithium-ion batteries can overheat, posing a fire hazard to consumers.”

    CPSC

  • Theme Switcher: fixing the theme editor breakage

    Version 2.0 of Mr Peer’s Theme Switcher is would be perfect, if it weren’t for the unfortunate breaking of WordPress’ built-in theme editor, causing all requests to open files for editing be redirected to the home page. The problem seems to be the theme parameter, which is used by both the built-in editor and Theme Switcher.

    Fixing this issue seemed to be as simple as replacing all isolated mentionings of theme in the plugin source with a new, non-ambiguous keyword. I chose switchto, and the resulting code is available behind the previous link.

    So, the parameter to switch themes with this modified version of the plugin is switchto=themename, and this eliminates the problem with the theme editor. Otherwise it should be identical to the original in functionality.