Posted in postgresql, perl, unicode
Fri, 29 Sep 2006 18:21:00 GMT
Perl has two UTF-8 encodings, utf8 which is Perl's liberal version and UTF-8 which is a strict interpretation, aka utf-8-strict. The liberal version allows for encoded characters outside the UTF-8 character set, however you can run into problems when interoperating with applications that expect utf-8-strict, such as PostgreSQL. Here's a function I wrote to strictify utf8 to UTF-8 using the Encode core module:
use Encode;
sub strictify_utf8 {
my $data = shift;
if (Encode::is_utf8($data) && !Encode::is_utf8($data,1)) {
Encode::_utf8_off($data);
Encode::from_to($data, 'utf8', 'UTF-8');
Encode::_utf8_on($data);
}
return $data;
}
no comments
Posted in perl, unicode
Fri, 29 Sep 2006 18:00:00 GMT
I recently responded to someone asking how to get a Unicode hex codepoint from a Unicode literal on DevShed Forums. Since I think it may be more generally useful, here's my solution. The following function takes a unicode literal, converts it to a decimal representation using unpack and then converts it to hex usning sprintf:
sub codepoint_hex {
if (my $char = shift) {
return sprintf '%2.2x', unpack('U0U*', $char);
}
}
my $cp = codepoint_hex('カ'); # eq '30ab'
Read more...
2 comments
Posted in apple
Sun, 17 Sep 2006 07:04:00 GMT
The other day I went to a store to check out the 13", 15.4" and 17" MacBook/Pros and especially their keyboards and touchpad placement. One of my pet peeves regarding laptops is manufacturers that position the touchpad in the center of the area below the keyboard vs. centering it under the G and H keys where hands are normally positioned. While centering the touchpad against the laptop is an aesthetic (appearances) win, it loses out on ergonomics (actual human usage) because it requires hand/palm movement to effectively use the touchpad. Laptops that center the touchpad typically have your thumbs end up in the upper left corner of the touchpad rather than centered unless you move your hands. This is compared to centering the touchpad under the G and H keys the palms typically don't have to move to use the touchpad.
Read more...
7 comments
Posted in catalyst, perl
Tue, 05 Sep 2006 15:07:00 GMT
Whenever popular Perl sites are discussed, a number of large websites are mentioned with the usual suspects being Amazon, IMDB, LiveJournal, Slashdot and others. While this is a good list, what often doesn't get mentioned is the new Web 2.0 sites that Perl 5 is powering. Perl 5 web frameworks (such as Catalyst and Jifty), OO models (Moose) and other techniques (PAR) dramatically improve Perl for web development and large-scale projects making many complaints about the language irrelevant. These, when combined with CPAN, continue to make Perl 5 a very attractive language for new web apps.
Examples of Perl-powered Web 2.0 sites include del.icio.us, (which uses the Mason templating system / mini-framework), EditGrid (an AJAX-enhanced online spreadsheet running on the Catalyst framework) and Vox (a multi-user blogging site by Six Apart, maker of LiveJournal, MovableType and TypePad). Other sites include HiveMinder, IUseThis, and MighTyV. Of these six sites, four are running on the Catalyst framework. HiveMinder is built on the Jifty framework. Yahoo is even interested in developers with Perl/Catalyst skills along with C and Java for this Senior Software Engineering position (screenshot from jobs.perl.org). Screenshots and links of active sites are provided below.
 |
del.icio.us
Description: Social Bookmarking
Perl Framework: Mason
|
 |
EditGrid
Description: Online Spreadsheets
Perl Framework: Catalyst
|
Read more...
5 comments
Posted in typo, hacks
Sat, 02 Sep 2006 17:20:00 GMT
Benjamin Gorlick asked for WP-Notable-style social bookmarking/networking links on the #typo IRC channel so I put one together in the form of a single view (template file). WP-Notable, by Cal Evans, displays a row of icons with links to social bookmarking/networking sites under your blog article allowing for easy posting tovarious social bookmarking sites.
Read more...
6 comments