GithubHelp home page GithubHelp logo

lua-native's Introduction

About

Have trouble with printing UTF-8 stings or saving file with UTF-8 names on Windows?

lua-native is for you:

native.encode() converts from UTF-8 string to system current encoding on Windows.

On other system (Mac/Linux...) it just return the 1st argument.

local native = require('native')
local mbcs = native.encode(utf8string)
print(mbcs) -- prints correctly in Windows/Mac/Linux... console...

native.decode() converts from system default encoding to UTF-8 on Windows.

On other system (Mac/Linux...) it just return the 1st argument.

local native = require('native')
local lfs = require('lfs')

function attrdir(utf8_path)
	local native_path = native.encode(utf8_path)
	local utf8_filenames = {}
  for file in lfs.dir(native_path) do
      if file ~= "." and file ~= ".." then
          utf8_filenames[#utf8_filenames+1] = native.decode(file)
      end
  end
	return utf8_filenames
end

Build

  1. You need Lua for Windows installed. It will set a LUA_DEV environment variable for you.
  2. Setup a visual studio dll empty project named nconv, add header path $(LUA_DEV)\include and lib path $(LUA_DEV)\lib to options, and link with lua5.1.lib.
  3. Build the nconv.dll, and copy to $(LUA_DEV)\clibs.
  4. Run the test.lua for test.

Binary

Yes, build is boring, just get a copy of prebuild binary from the download area.

TODO

  1. Add to rock repos?

lua-native's People

Contributors

xpol avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.