This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix utf8 scripts, add test. Thanks Urban.

  • Loading branch information...
1 parent e8a5d3d commit b1588e78d97b6b1ed83e1afd3f84d99f7e0406a6 @ry ry committed Jul 20, 2009
Showing with 21 additions and 7 deletions.
  1. +8 −4 src/file.cc
  2. +2 −2 src/file.js
  3. +10 −0 test/mjsunit/test-utf8-scripts.js
  4. +1 −1 website/api.txt
View
@@ -248,17 +248,19 @@ AfterUtf8Read (eio_req *req)
HandleScope scope;
- Local<Value> argv[1];
+ Local<Value> argv[2];
if (req->result == 0) {
// eof
argv[0] = Local<Value>::New(Null());
+ argv[1] = Integer::New(0);
} else {
char *buf = reinterpret_cast<char*>(req->ptr2);
argv[0] = String::New(buf, req->result);
+ argv[1] = Integer::New(req->result);
}
- promise->EmitSuccess(1, argv);
+ promise->EmitSuccess(2, argv);
return 0;
}
@@ -273,10 +275,11 @@ AfterRawRead(eio_req *req)
}
HandleScope scope;
- Local<Value> argv[1];
+ Local<Value> argv[2];
if (req->result == 0) {
argv[0] = Local<Value>::New(Null());
+ argv[1] = Integer::New(0);
} else {
char *buf = reinterpret_cast<char*>(req->ptr2);
size_t len = req->result;
@@ -285,9 +288,10 @@ AfterRawRead(eio_req *req)
array->Set(Integer::New(i), Integer::New(buf[i]));
}
argv[0] = array;
+ argv[1] = Integer::New(req->result);
}
- promise->EmitSuccess(1, argv);
+ promise->EmitSuccess(2, argv);
return 0;
}
View
@@ -20,14 +20,14 @@ node.fs.cat = function (path, encoding) {
read_promise.addErrback(function () { cat_promise.emitError(); });
- read_promise.addCallback(function (chunk) {
+ read_promise.addCallback(function (chunk, bytes_read) {
if (chunk) {
if (chunk.constructor == String)
content += chunk;
else
content = content.concat(chunk);
- pos += chunk.length;
+ pos += bytes_read;
readChunk();
} else {
cat_promise.emitSuccess([content]);
@@ -0,0 +1,10 @@
+include("mjsunit.js");
+
+// üäö
+
+puts("Σὲ γνωρίζω ἀπὸ τὴν κόψη");
+
+function onLoad () {
assertTrue( /Hellö Wörld/.test("Hellö Wörld") );
+}
+
View
@@ -479,7 +479,7 @@ reading from in the file.
+encoding+ is either +node.UTF8+
or +node.RAW+.
+
-- on success: returns +data+, what was read from the file.
+- on success: returns +data, bytes_read+, what was read from the file.
- on error: no parameters.

0 comments on commit b1588e7

Please sign in to comment.