Permalink
Browse files

Merge pull request #11 from nrenner/utf8

also use ByteBuffer.readUTF8StringBytes for Node.js
  • Loading branch information...
2 parents 257f621 + 7657428 commit f70ebaca5e50827ed4f52fbe87badfd66de35a0a @marook committed Mar 7, 2014
Showing with 7 additions and 9 deletions.
  1. BIN example/test.pbf
  2. +0 −5 lib/browser/buffer.js
  3. +0 −1 lib/nodejs/buffer.js
  4. +2 −3 lib/pbfParser.js
  5. +4 −0 test/pbfTest.js
  6. BIN test/test.pbf
  7. +1 −0 test/test.xml
View
Binary file not shown.
View
@@ -2,16 +2,11 @@ function readPBFElementFromBuffer(buffer, pbfDecode, callback){
return callback(null, pbfDecode(buffer));
}
-function pbfBufferToBuffer(src, srcOffset, len){
- return src.readUTF8StringBytes(len, srcOffset).string;
-}
-
function blobDataToBuffer(blob){
return new Uint8Array(blob.toArrayBuffer());
}
module.exports = {
readPBFElementFromBuffer: readPBFElementFromBuffer,
- pbfBufferToBuffer: pbfBufferToBuffer,
blobDataToBuffer: blobDataToBuffer
};
View
@@ -48,6 +48,5 @@ function blobDataToBuffer(blob){
module.exports = {
readPBFElementFromBuffer: readPBFElementFromBuffer,
- pbfBufferToBuffer: pbfBufferToBuffer,
blobDataToBuffer: blobDataToBuffer
};
View
@@ -88,11 +88,10 @@ function getStringTableEntry(i){
s = this.s[i];
- // TODO specify toString encoding
-
// obviously someone is missinterpreting the meanding of 'offset'
// and 'length'. they should be named 'start' and 'end' instead.
- return buf.pbfBufferToBuffer(s, s.offset, s.length - s.offset).toString();
+ return s.readUTF8StringBytes(s.length - s.offset, s.offset).string;
+
}
function extendStringTable(st){
View
@@ -180,6 +180,10 @@ describe('pbf read', function(){
way.tags.highway.should.be.equal('service');
});
+ it('then way has tag name=üßé€', function(){
+ way.tags.name.should.be.equal('üßé€');
+ });
+
it('then first way node ref has id 304994979', function(){
way.nodeRefs[0].should.be.equal('304994979');
});
View
Binary file not shown.
View
@@ -20,5 +20,6 @@
<nd ref="304994981"/>
<tag k="access" v="private"/>
<tag k="highway" v="service"/>
+ <tag k="name" v="üßé€"/>
</way>
</osm>

0 comments on commit f70ebac

Please sign in to comment.