@accounter/shaam6111-generator
Version:
Fully typed application that generates, parses, and validates SHAAM 6111 tax reports.
23 lines (20 loc) • 683 B
text/typescript
import iconv from 'iconv-lite';
/**
* Converts a UTF-8 string to a Windows-1255 encoded buffer.
* @param input The input string to encode.
* @returns A Buffer containing the Windows-1255 encoded data.
*/
export function toWindows1255(input: string): Buffer {
if (typeof input !== 'string') {
throw new TypeError('Input must be a string');
}
return iconv.encode(input, 'windows-1255');
}
/**
* Converts a Windows-1255 encoded buffer to a UTF-8 string.
* @param buffer The input buffer to decode.
* @returns A string decoded from the Windows-1255 buffer.
*/
export function fromWindows1255(buffer: Buffer): string {
return iconv.decode(buffer, 'windows-1255');
}