Created
October 17, 2014 19:52
-
-
Save torque/25c8380e198daa22e00c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fuckWindows = ( logString ) -> | |
ffi.cdef [[int WideCharToMultiByte( unsigned int, unsigned int, const char*, int, char*, int, void*, void* );]] | |
CP_UTF8 = 65001 | |
logLength = math.ceil #logString/2 | |
buffSize = 1 + ffi.C.WideCharToMultiByte CP_UTF8, 0, logString, logLength, nil, 0, nil, nil | |
if 0 == buffSize | |
error "Shit's fucked i aint helping." | |
utf8String = ffi.new "char[?]", buffSize | |
status = ffi.C.WideCharToMultiByte CP_UTF8, 0, logString, logLength, utf8String, buffSize, nil, nil | |
if 0 == status | |
error "Shit's fucked bye." | |
return ffi.string utf8String, buffSize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment