From: christian.plesner.hansen@gmail.com Date: Wed, 10 Sep 2008 11:41:48 +0000 (+0000) Subject: Fixed bug #57. Introduced String::Utf8Value and replaced a bunch of X-Git-Tag: upstream/4.7.83~25408 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6974e4b2c7633f1844df0aecd77e90f68c16fbc4;p=platform%2Fupstream%2Fv8.git Fixed bug #57. Introduced String::Utf8Value and replaced a bunch of uses of String::AsciiValue with String::Utf8Value. Fixed shell sample 'load' so it doesn't print error messages. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@254 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/include/v8.h b/include/v8.h index c72bb2e7b..430165ae9 100644 --- a/include/v8.h +++ b/include/v8.h @@ -879,6 +879,21 @@ class EXPORT String : public Primitive { /** Creates an undetectable string from the supplied utf-16 data.*/ static Local NewUndetectable(const uint16_t* data, int length = -1); + /** + * Converts an object to a utf8-encoded character array. Useful if + * you want to print the object. + */ + class EXPORT Utf8Value { + public: + explicit Utf8Value(Handle obj); + ~Utf8Value(); + char* operator*() { return str_; } + int length() { return length_; } + private: + char* str_; + int length_; + }; + /** * Converts an object to an ascii string. * Useful if you want to print the object. @@ -888,8 +903,10 @@ class EXPORT String : public Primitive { explicit AsciiValue(Handle obj); ~AsciiValue(); char* operator*() { return str_; } + int length() { return length_; } private: char* str_; + int length_; }; /** @@ -900,8 +917,10 @@ class EXPORT String : public Primitive { explicit Value(Handle obj); ~Value(); uint16_t* operator*() { return str_; } + int length() { return length_; } private: uint16_t* str_; + int length_; }; }; diff --git a/samples/process.cc b/samples/process.cc index 57710b377..6567f080b 100644 --- a/samples/process.cc +++ b/samples/process.cc @@ -137,7 +137,7 @@ static Handle LogCallback(const Arguments& args) { if (args.Length() < 1) return v8::Undefined(); HandleScope scope; Handle arg = args[0]; - String::AsciiValue value(arg); + String::Utf8Value value(arg); HttpRequestProcessor::Log(*value); return v8::Undefined(); } @@ -206,7 +206,7 @@ bool JsHttpRequestProcessor::ExecuteScript(Handle script) { // Compile the script and check for errors. Handle