1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iconv-liteで対応している文字コード一覧を出力する

Posted at
encodings = require "iconv-lite/encodings"

# 配列から重複を除く処理が標準でないのでCoffeeScript Cookbookから借用
# https://coffeescript-cookbook.github.io/chapters/arrays/removing-duplicate-elements-from-arrays
array_unique = (array) ->
  output = {}
  output[array[key]] = array[key] for key in [0...array.length]
  value for key, value of output

existsEncodings = []
for key, val of encodings
  # 頭が"_"で始まるもの(_internal等)は恐らく内部処理用なので飛ばす
  continue if key.match /^_/
  # keyは数字のみでvalに名称らしきものが入っているものが多数あったので
  if typeof val == "string"
    existsEncodings.push val
  else
    existsEncodings.push key

existsEncodings = array_unique existsEncodings.sort()

for enc in existsEncodings
  console.log enc

本当に対応しているかを確認するならばiconv = require "iconv-lite"してiconv.encodingExists()で確認するとよい。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?