LUA ASCII碼轉字符 和 字符轉ASCII碼函數 string.byte() | string.char()

一,string.byte()函數:

local tmp= "1"
print(string.byte(tmp))  --輸出49
print(tmp:byte())--輸出49

tmp = "123"  --默認轉換第一個
print(string.byte(tmp))--輸出49
print(tmp:byte())--輸出49

print(string.byte(tmp,1,3))--輸出49  50 51
print(tmp:byte())--輸出49

 

二,string.char()函數

local tmp = 49
print(string.char(tmp))  --輸出1

print(string.char(49,50,51)) --輸出123

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章