语法:buf.copy(target,targetStart,sourceStart,sourceEnd);
var str1="垂死病中惊坐起,暗风吹雨入寒窗";
var str2="流连忘返难千日,谈笑风生又一年";
var buf1=new Buffer(str1,‘utf-8‘);
var buf2=new Buffer(str2,‘utf-8‘);
//将buf2的[24,45)偏移量的内容嫁接到buf1的[24,∞)内
var byteLen=buf2.copy(buf1,24,24,45);
console.log(byteLen);
//21。即被截取的“谈笑风生又一年”七个汉字的编码长度
console.log(buf1.toString("utf-8"));
//垂死病中惊坐起,谈笑风生又一年
原文:https://www.cnblogs.com/Syinho/p/12613723.html