Closed kynx closed 8 years ago
ICU/ECMA-402 support should be available without modifications to V8Js once you don't compile with i18nsupport=off
. You actually don't have to call InitializeICU
yourself, V8 does by itself.
You tried with a V8 with i18nsupport (which is the default):
stesie@hahnschaaf:~/Projekte/v8js-php7$ /opt/php-7.0.0RC3/bin/php -n -d extension_dir=./modules -d extension=v8js.so -a
Interactive shell
php > $v8 = new V8Js();
php > $v8->blar = 3500;
php > $v8->executeString(' var_dump( new Intl.NumberFormat("en-US").format(PHP.blar)); ');
string(5) "3,500"
php > $v8->executeString(' var_dump( new Intl.NumberFormat().format(PHP.blar)); ');
string(5) "3.500"
... looks like it just works to me :-)
my box has German locale, hence the dot for digit grouping
Hey, fantastic. Serves me right for mucking about to get v8 compiled with use_system_icu - must've missed v8js doing the right thing amidst all my swearing :)
Any chance of getting this built in?
From the docs it looks as simple as adding
v8::v8::InitializeICU()
tov8js_v8_init()
. But when I tried that it blew up. Turned out my v8 was built withi18nsupport=off
and I'm not really sure how to test for that.