Sample code for 30+ languages & platforms
React Native

Appending Strings to BinData

Demonstrates appending strings to a BinData..

Chilkat React Native Downloads

React Native
import { BinData } from '@chilkat/react-native'

function chilkatExample() {
  const binData1 = new BinData();

  // Append a string using a 1-byte per char encoding
  binData1.appendString('This is a test', 'windows-1252');
  console.log(binData1.getEncoded('hex'));
  // The bytes contained within the binData1 (in hex) are: 54,68,69,73,20,69, ...

  const binData2 = new BinData();

  // Append a string using a 2-byte per char encoding
  binData2.appendString('This is a test', 'utf-16');
  console.log(binData2.getEncoded('hex'));
  // The bytes contained within the binData2 (in hex) are: 54,00,68,00,69,00,73,00,20,00,69,00, ...
}