Another way to autofill your profile in HTML forms

NTT DoCoMo, teamed with NEC, does this thing again: the new "iprof" HTML attribute and new input element with type="quote" to autofill your system profile to HTML forms.

<INPUT type="text" name="phone-number" iprof="tel1">
<INPUT type="quote" value="auto-fill profile">

iprof="tel1" tells the browser what field of system profile you want to auto-fill, and by clicking this new "quote" input element, which would look similar to (or actually identical to) type="button" buttons, the browser will auto-populate the fields to input fields, which will then submitted to the form later.

I just can't find any response other than "WTF!?" to this new specification.

I admit that this auto populating feature itself would be very useful: It's really hard and annoying to type your date of birth, street address and email etc. when you sign up for a new site using this small cellphone devices, and this autofill spec would allow developers to make their site's user experience better by adding some special tags and attributes, but then why am I angry?: 

  1. This is 2009, not 1998 when they needed to implement their own CHTML spec.
  2. This is not a standard and is not valid per any of XHTML Mobile profile per se.
  3. This works ONLY for users with new DoCoMo + NEC phones. This is why Japan is called "Galapagos of Mobile phones".

There're already too many ways to do this autofill thing in the wild: Safari autofills your name, street address and date of birth from Address Book (by default, and that could cause privacy issues with CSS hacks) and Microsoft IE also has VCARD_NAME attribute to match with vCard field to auto populate.

Look how Google bets big on HTML 5. I think it should make more sense to introduce standards so that developers can write some JavaScript function to prompt users (for security) to auto-fill their profile from system profile, probably by adding hCard markup to their form fields

NTT DoCoMo and their partner makers market share (in Japan) is huge, so they can add whatever random new attributes to their HTML spec and developers should eventually implement something special for them. That sucks. They can take this opportunity to become the leadership to improve HTML by working with folks like WHAT-WG

And by "this thing again" i meant this is not the first time NTT DoCoMo does this. They have form utn attribute to send SIM unique ID in User-Agent, or form or A ics attribute that sends the closest wireless station geo location as a query parameter.

It's so disappointing to see this new, apparently-useful-but-only-works-for-certain-phones feature.

JSON, jQuery and some Unicode characters (U+2028)


You have a web application that generates JSON dynamically from the data in your database, which probably comes from the cloud. Your data might have some weird strings, like U+2028 the Unicode LINE SEPARATOR character.
When you use Perl's JSON::XS, or probably other JSON encoder modules as well, it gives you an UTF-8 JSON data like this:

  {"text":"Foo[\xe2\x80\xa8]Bar"}

Note that this [\xe2\x80\xa8] stands for 3-byte strings that represent UTF-8 encoding of one character U+2028. I think this is a valid JSON UTF-8 representation, but since jQuery uses browser's built-in eval() function to parse JSON, this JSON data can't be parsed with Safari and Firefox. You can confirm that by pasting this to your Location bar. 

  javascript:try{eval('({"text":"Foo\u2028Bar"})')} catch(e){alert(e)}

This will give you a Syntax Error.

There's a couple of workarounds to this. The easiest is to escape high-bit characters as \uXXXX notation in the server side. In JSON::XS it's as simple as JSON::XS->new->ascii->encode($data); intead of ->utf8. This is a little weird to use this option since this changes ALL non-ascii characters in \uXXXX not only these "special" characters like U+2028, but it's probably the most straightforward anyway.

The other fix would be not using jQuery's native JSON parser which is just eval(). Instead you get the text data using dataType: 'text' and use token-based JSON decoder like Crockford's. There might be JSON plugins to do this as well. jquery-json has evalJSON() method but hm, this seems to use eval() as well. And that approach would slow the parsing significantly anyway.

Mac OS X Security Update 2009-001 might break your Perl (CPAN)

A couple of my friends on IRC have told me this, and since I'm using 10.4.11 I couldn't verify, but the latest Mac OS X Security Update 2009-001 apparently breaks your Perl, if you  

  • are using Mac OS X 10.5 (Leopard)
  • and are using Perl that comes with Mac OS X  
  • and have upgraded several core modules with CPAN in the past  
 In other words, it doesn't break yours if you a) haven't ever used CPAN with your perl, b) are on Tiger like me or c) have built Perl yourself, or are using other Perl like MacPorts one.

Once your Perl gets broken, you'll see errors like this:
% perl -MIO
IO object version 1.22 does not match bootstrap parameter 1.23
at /System/Library/Perl/5.8.8/darwin-thread-multi-2level/XSLoader.pm
line 94.

Compilation failed in require.
BEGIN failed--compilation aborted.

This is because the Security Update brings (old) IO.bundle with version 1.22 but your IO.pm has been updated to the latest 1.23 on CPAN shell. (But hey, 1.23 was released in 2006 ... Why do you bring that ancient version back, Apple!?)

The fix is to update IO.pm to 1.23, but since IO.pm is now broken, you can't even run CPAN shell to do this (Ugh!). You need to go to CPAN and grab IO-1.2301.tar.gz, unpack it and run "perl Makefile.PL; make; sudo make install" to fix this. You probably need to do the same against Scalar::Util and Storable.

This is another reason why you shouldn't use Perl that comes from vendors (Apple isn't any different from Fedora on this!) or use stuff like local::lib to keep system modules clean.

(Thanks lopnor and typester for the information!)

Politics

Obama's address was great. The new whitehouse website has a blog, a valid Atom 1.0 feeda beautiful robots.txt file and all of the content are licensed under Creative Commons license. We also have a humor of renaming the end of Bush St. to the beginning of Obama St.


I don't want to sound too political or cynical but can't stand: what about Japan? Kanji reading test for the prime minister. Stop doing childish things and wasting people's taxes.

Mile woes


Yes it's this season of  the year. I flew 42709 miles (70% of the actual) this year and want to make it 50000 to get to the ANA platinum. I plan to fly back to Tokyo and SFO-NRT would make it 49900. Short of 100 miles :)

The options I have:

  1. On 22nd, fly to Los Angeles with UA and then LAX -> NRT with ANA. The return flight is NRT -> SFO. This will add extra 500 miles for me and the price is almost the same. This is more economical and ridiculous choice :)
  2. Buy "Premium Economy" flight for SFO-NRT. I need to pay $500 more but will get 2000 more miles because it gives me 100% of the flight mile instead of 70%.
  3. Get some domestic flight while I'm in Japan: for example, go to Kyoto via Shinkansen for a day trip and then fly back from Osaka to Tokyo. This costs like $250 and gives me 200 miles or so. 
  4. Get some domestic flight while I'm in US. for instance, 1-night trip to Seattle and stay in the next weekend would just cost $200. 
  5. Not bother getting 50k miles and instead upgrade my ANA credit card to super flyers card. This doesn't give me the 100% bonus miles for every flight but I'll get lifetime Star Alliance Gold and can use ANA lounge for all flights (even in economy). This costs the annual membership fee $120.
Hmm :)

Old school Videogames in HD


Fully working Flash based Tetris game that should work in HD screen. It's so awesome that would probably make you mad :) There's also a link to Space Invador in HD but I couldn't find the swf link.

Did you see that ludicrous display last night?

It was tough watching The IT Crowd S02E02 on my flight while everyone else was asleep, because it was hard for me to keep from laughing out. I especially liked the first few minutes where Moss found the very useful bluffball.co.uk (grr it doesn't really exist!) and Jen had a date with Michael who looks like a magician.

Hearts Canon SD 880

If you follow me on Flickr you might've noticed that the amount of pictures I upload to Flickr has increased dramatically recently. It's not just because I'm back home in Japan but also I got a new camera Canon SD880 (or IXY 920 is in Japan) and it works really well.

It's a straight upgrade from my previous model Canon SD800 but this one has a new image processing engine Digic4 and has automatic face recognition, and really smart automatic exposure. Those ones I uploaded to Flickr didn't have any customization besides that I change the color to VIVID, and all other ISO and exposure settings were automatic (besides I made the default exposure to lower like -2/3). Ken Rockwell has more reviews and tips.


IMG_4025.JPG

IMG_3988.JPG


I highly recommend this camera as a main compact if you're not DSLR photo geek, or even if you are, the best alternative if you want to take daily photos without carrying around the heavy one.

Path::Class and Unicode filename woes

(I've been working on the new TypePad connect and profile stuff, so this feels more natural to get back to blogging on TypePad :)


I've restarted my love of hacking RSS feeds and Perl (aka Plagger) and launched my new toy project Remedie the pluggable Media Center application written in Perl and backed by Plagger. I'll talk about it more on that later, but this has already proven its usefulness and addictivity so that I can't live without this.

The one thing I hate to write and see in my code is the code to deal with Win32 though. Based on the recent popularity I picked Moose and Path::Class to represent the local file path in Remedie code, but it just started to hurt me, because Path::Class does special care of Win32 filenames and file paths, like changing directory separater to backslash (\) while Perl itself doesn't have any problem with forward slash even if it's on win32 file systems. charsbar is trying to deal with that by writing another Path::Class compatible class called Path::Extended.

The other problem is Unicode filenames. In most UNIX operating systems like Mac OS X or Linux we just use utf-8 filenames, but on Win32 it's different. They have local code page, which is usually cp932 in Windows running in  Japanese environment, and they also have wide filename API to deal with UCS (UTF-16) filenames without encoding/decoding filenames to the local encoding (cpXXX). Unfortunately perl itself can't handle those Unicode filenames natively using its built-in open() functions. You should use Win32API::File to handle them.

As a starter, I wrote Path::Class::Unicode that encodes filenames to the local encoding (cpXXX) when it's opening a file, but eventually we might need IO::Handle compatible proxy that allows you to read and print that is eventually proxied to API calls to Win32API::File.

Going to OSCON

I'm going to Portland for OSCON 2008, so do lots of engineers from Six Apart. I won't give a talk, but hat's new for us this year would be that we have a booth! Come by to talk to us and steal some stickers or t-shirts. Rumor says that we'll have a free beer drinking at our suite one of those nights. I'll keep you updated on my twitter.

My Photo

del.icio.us/miyagawa

Flickr

  • www.flickr.com

My Last FM

Blog powered by TypePad

Blog Search

Lingr