Split utf8 from quoted printable

This commit is contained in:
Manuel Friedli 2017-03-15 00:09:57 +01:00
parent 644c3c42b6
commit 9b29d638d1
4 changed files with 4 additions and 0 deletions

View file

@ -2,6 +2,7 @@ import {Converter} from "./converter";
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class QuotedPrintableDecoder implements Converter {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) {
}

View file

@ -2,6 +2,7 @@ import {Converter} from "./converter";
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class QuotedPrintableEncoder implements Converter {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) {
}

View file

@ -0,0 +1,24 @@
import {Converter} from "./converter";
import {NativeLibraryWrapperService} from "../nativelibrarywrapper.service";
export class UTF8Decoder implements Converter {
constructor(private nativeLibraryWrapperService:NativeLibraryWrapperService) {
}
getDisplayname():string {
return "Decode UTF-8";
}
getId():string {
return "decodeutf8";
}
convert(input:string):string {
try {
return this.nativeLibraryWrapperService.utf8.decode(input);
} catch (error) {
throw new Error("The input can not be interpreted a valid UTF-8 encoded string. May be corrupt?");
}
}
}

View file

@ -0,0 +1,24 @@
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?");
}
}
}