const str = "Hello, 世界";

console.log("String:", str);

// Accessing UTF-16 code units
for (let i = 0; i < str.length; i++) {
    console.log(`Character at position ${i}: ${str[i]}`);
}

// Handling multi-byte characters correctly with Buffer
const buffer = Buffer.from(str, 'utf-8');
for (let i = 0; i < buffer.length; i++) {
    console.log(`Byte at position ${i}: ${buffer[i].toString(16)}`);
}