MCPcopy
hub / github.com/zxing-js/library / castAsNonUtf8Char

Method castAsNonUtf8Char

src/core/common/StringUtils.ts:46–52  ·  view source on GitHub ↗
(code: number, encoding: Charset = null)

Source from the content-addressed store, hash-verified

44 // EUC_JP.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING);
45
46 static castAsNonUtf8Char(code: number, encoding: Charset = null) {
47 // ISO 8859-1 is the Java default as UTF-8 is JavaScripts
48 // you can see this method as a Java version of String.fromCharCode
49 const e = encoding ? encoding.getName() : this.ISO88591;
50 // use passed format (fromCharCode will return UTF8 encoding)
51 return StringEncoding.decode(new Uint8Array([code]), e);
52 }
53
54 /**
55 * @param bytes bytes encoding a string, whose encoding should be guessed

Callers 2

getEncodedDataMethod · 0.80
appendMethod · 0.80

Calls 2

getNameMethod · 0.80
decodeMethod · 0.65

Tested by

no test coverage detected