Chromium Code Reviews| Index: src/extensions/experimental/i18n-utils.cc |
| =================================================================== |
| --- src/extensions/experimental/i18n-utils.cc (revision 7878) |
| +++ src/extensions/experimental/i18n-utils.cc (working copy) |
| @@ -29,6 +29,8 @@ |
| #include <string.h> |
| +#include "unicode/unistr.h" |
| + |
| namespace v8 { |
| namespace internal { |
| @@ -40,4 +42,28 @@ |
| dest[length - 1] = '\0'; |
| } |
| +// static |
| +bool ExtractStringSetting(const v8::Handle<v8::Object>& settings, |
| + const char* setting, |
| + icu::UnicodeString* result) { |
| + if (!setting || !result) return false; |
| + |
| + v8::HandleScope handle_scope; |
| + v8::TryCatch try_catch; |
| + v8::Handle<v8::Value> value = settings->Get(v8::String::New(setting)); |
| + if (try_catch.HasCaught()) { |
| + return false; |
| + } |
| + // No need to check if |value| is empty because it's taken care of |
| + // by TryCatch above. |
| + if (!value->IsUndefined() && !value->IsNull() && value->IsString()) { |
| + v8::String::AsciiValue ascii_value(value); |
| + if (*ascii_value == NULL) return false; |
| + icu::UnicodeString tmp(*ascii_value, -1, US_INV); |
| + result->setTo(tmp); |
|
jungshik at Google
2011/05/13 23:37:53
*result = icu::UnicodeString::fromUTF8(*ascii_valu
Nebojša Ćirić
2011/05/17 20:40:37
Yours is more readable.
On 2011/05/13 23:37:53, J
|
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| } } // namespace v8::internal |