Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created June 3, 2017 05:52
Show Gist options
  • Save zr-tex8r/96dc09a6696784d75fb4169d5c9cd8bc to your computer and use it in GitHub Desktop.
Save zr-tex8r/96dc09a6696784d75fb4169d5c9cd8bc to your computer and use it in GitHub Desktop.
Lua: CP932の文字列で ’\’→’/’ の変換を行う
-- 文字コードはCP932
function slashify(str)
return (tostring(str):gsub("[\x81-\x9f\xe0-\xfc]?.", { ["\\"] = "/" }))
end
print(slashify([[ふが\ほげ/予定表\アレ/コレ\ソレ]]))
-- ふが/ほげ/予定表/アレ/コレ/ソレ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment