Skip to content

Question: switch case for strings not work #1643

Closed
@nuintun

Description

@nuintun
export function stringEncode(value: string, encoding: string): ArrayBuffer {
  switch (encoding.toUpperCase()) {
    case 'UTF8':
    case 'UTF-8':
      return String.UTF8.encode(value);
    case 'UTF16':
    case 'UTF-16':
      return String.UTF16.encode(value);
    default:
      throw new TypeError('Unsupported encoding ' + encoding);
  }
}

屏幕截图 2021-01-30 094644

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions