Sha256: a71d572a9a874dd5142749ad0f1e334256fd6526bd398012bfa2fb4a93ab9d36

Contents?: true

Size: 876 Bytes

Versions: 72

Compression:

Stored size: 876 Bytes

Contents

'use strict';
var Buffer = require('../../').Buffer;


var assert = require('assert');

// ASCII conversion in node.js simply masks off the high bits,
// it doesn't do transliteration.
assert.equal(Buffer.from('hérité').toString('ascii'), 'hC)ritC)');

// 71 characters, 78 bytes. The ’ character is a triple-byte sequence.
var input = 'C’est, graphiquement, la réunion d’un accent aigu ' +
            'et d’un accent grave.';

var expected = 'Cb\u0000\u0019est, graphiquement, la rC)union ' +
               'db\u0000\u0019un accent aigu et db\u0000\u0019un ' +
               'accent grave.';

var buf = Buffer.from(input);

for (var i = 0; i < expected.length; ++i) {
  assert.equal(buf.slice(i).toString('ascii'), expected.slice(i));

  // Skip remainder of multi-byte sequence.
  if (input.charCodeAt(i) > 65535) ++i;
  if (input.charCodeAt(i) > 127) ++i;
}

Version data entries

72 entries across 71 versions & 15 rubygems

Version Path
sumomo-0.10.8 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
optimacms-0.1.61 spec/dummy/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.10.4 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.10.3 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.10.2 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.10.1 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.10.0 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
disco_app-0.18.0 test/dummy/node_modules/buffer/test/node/test-buffer-ascii.js
disco_app-0.18.2 test/dummy/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
disco_app-0.16.1 test/dummy/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/buffer/test/node/test-buffer-ascii.js
disco_app-0.15.2 test/dummy/node_modules/buffer/test/node/test-buffer-ascii.js