Internationalization and localization tools


Locale-Sensitive JavaScript NodeJS Method

buf.copy(targetBuffer[, targetStart[, sourceStart[, sourceEnd]]]);

Internationalization (I18n) Method Overview

The buf.copy method copies data from a region of this Buffer to a region of the target Buffer. The target memory region is allowed to overlap with the source region.

For Example:
const buf1 = Buffer.allocUnsafe(26);
const buf2 = Buffer.allocUnsafe(26).fill('!');

for (let i = 0 ; i < 26 ; i++) {
	buf1[i] = i + 97; // 97 is ASCII a
}

buf1.copy(buf2, 8, 16, 20);
console.log(buf2.toString('ascii', 0, 25));
	// Prints: !!!!!!!!qrst!!!!!!!!!!!!!
				

Click here for additional details.

I18n Issues

If the buffer contains a string, then any of the the targetStart, sourceStart, and sourceEnd parameters may be based upon the number of string characters passed. However, different unicode characters may require varying amounts of bytes to encode.

Suggested Replacement

If providing a start or end setting for a string buffer, calculate the bytelength of the desired sections relevant to the encoding used. Do not assume the bytelength will be directly proportional to the number of string characters.

Globalyzer will detect this method and report it as an i18n issue. If you have determined that the call is being handled correctly, you can use Globalyzer's Ignore Comment functionality to ensure that it isn't picked up in a subsequent scan.



Locale-Sensitive JavaScript Methods

 

Lingoport internationalization and localization services and software