/luaiconv

lua module iconv automatic conversion

Primary LanguageCMIT LicenseMIT

luaiconv

Copyright (c) 2013-2018 brinkqiang (brink.qiang@gmail.com)

luaiconv License blog Open Source Love GitHub stars GitHub forks

Build status

Linux Mac Windows
lin-badge mac-badge win-badge

env

install cmake

Intro

luaiconv

local luaiconv = require("luaiconv")

local test_str = "谦逊是藏于土中甜美的根,所有崇高的美德由此发芽滋长 hello"
print("[1]" .. luaiconv.detect(test_str))
print("[2]" .. test_str)
print("[3]" .. luaiconv.toLatin(test_str))
print("[4]" .. luaiconv.toUtf8(test_str))
print("[5]" .. luaiconv.toAscii(test_str))
print("[6]" .. luaiconv.toUtf8(luaiconv.toUtf8(test_str)))
print("[7]" .. luaiconv.toGbk(test_str))
print("[8]" .. luaiconv.toGb18030(test_str))
print("[9]" .. luaiconv.convert("utf-8", "gb18030", test_str))
print("[10]" .. luaiconv.convert("gb18030", "utf-8", test_str))

windows output

lua ../script/main.lua
[1]utf-8
[2]瀵嗘秴鐡︾殑鐚ご楣板湪榛勬槒璧烽 hello
[3] hello
[4]瀵嗘秴鐡︾殑鐚ご楣板湪榛勬槒璧烽 hello
[5] hello
[6]瀵嗘秴鐡︾殑鐚ご楣板湪榛勬槒璧烽 hello
[7]谦逊是藏于土中甜美的根,所有崇高的美德由此发芽滋长 hello
[8]谦逊是藏于土中甜美的根,所有崇高的美德由此发芽滋长 hello
[9]鐎靛棙绉撮悺锔炬畱閻氼偄銇旀ィ鏉挎躬姒涘嫭妲掔挧鐑筋棧 hello
[10]密涅瓦的猫头鹰在黄昏起飞 hello

linux output

./lua ../script/main.lua
[1]utf-8
[2]谦逊是藏于土中甜美的根,所有崇高的美德由此发芽滋长 hello
[3]???????????? hello
[4]谦逊是藏于土中甜美的根,所有崇高的美德由此发芽滋长 hello
[5]???????????? hello
[6]谦逊是藏于土中甜美的根,所有崇高的美德由此发芽滋长 hello
[7]èͷӥello
[8]èͷӥello
[9]瀵嗘秴鐡︾殑鐚ご楣板湪榛勬槒璧烽 hello
[10]èͷӥello

Contacts

Join the chat

Thanks