converter/src/app/converter/quotedprintabledecoder.ts

25 lines
649 B
TypeScript
Raw Normal View History

2016-09-20 22:02:38 +02:00
import {Converter} from "./converter";
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
2016-09-20 22:02:38 +02:00
export class QuotedPrintableDecoder implements Converter {
2017-03-15 00:09:57 +01:00
constructor(private nativeLibraryWrapperService: NativeLibraryWrapperService) {
}
2016-09-20 22:02:38 +02:00
getDisplayname(): string {
return "Decode quoted printable";
}
2016-09-20 22:02:38 +02:00
getId(): string {
return "decodequotedprintable";
}
2016-09-20 22:02:38 +02:00
convert(input: string): string {
try {
return this.nativeLibraryWrapperService.quotedPrintable.decode(input);
} catch (error) {
throw new Error("The input can not be interpreted as quoted-printable. May be corrupt?");
2016-09-20 22:02:38 +02:00
}
}
2016-09-20 22:02:38 +02:00
}