import {Converter} from "./converter"; import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service"; export class UTF8Encoder implements Converter { constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) { } getDisplayname():string { return "Encode UTF-8"; } getId():string { return "encodeutf8"; } convert(input:string):string { try { return this.nativeLibraryWrapperService.utf8.encode(input); } catch (error) { throw new Error("The input can not be encoded as UTF-8. May be corrupt?"); } } }