lib-utils-ts
Version:
<img src="https://img.shields.io/npm/v/lib-utils-ts"/> <img src="https://img.shields.io/snyk/vulnerabilities/npm/lib-utils-ts"/> <img src="https://img.shields.io/npm/l/lib-utils-ts"/> <img src="https://img.shields.io/github/languages/top/devGnode/lib-util
37 lines • 1.16 kB
text/typescript
import {Enum} from "../../Enum";
import {IllegalArgumentException} from "../../Exception";
/***
* @writer maroder
* @version 1.0-R-JSTrip
*
* js not support utf-16
* formCharCode manage - 0x0000 - 0x0FFF
*/
export class ENCODING extends Enum{
//
.args(null) static readonly ASCII:ENCODING;
.args(null) static readonly BINARY:ENCODING;
.args("ISO-8851-1") static readonly ISO_8851_1:ENCODING;
.args("UTF-8") static readonly UTF_8:ENCODING;
/***
*/
private readonly stringName:string;
/***
* @param {string} name
*/
private constructor(name:string) {super();this.stringName = name;}
/***
* @return {string}
*/
public toString(): string {return this.stringName==null ? super.toString() : this.stringName;}
/***
* @param {string} value
* @return {T}
*/
public static valueOf<T extends Enum>(value:string):T{
try {return super.valueOf(value.replace(/-/gi, "_"));}catch (e) {
throw new IllegalArgumentException(`Unknown charset encoding '${value}'`);
}
}
}
Object.package(this);