|
发表于 2010-2-8 20:14:02
|
显示全部楼层
这只是进制的不同表示而已
[jass]string StringMap = "0123456789,,,,,,,ABCDEFGHIJKLMNOPQRSTUVWXYZ,,,,,,abcdefghijklmnopqrstuvwxyz"
function String2Id takes string str returns integer
local string sub
local integer i = 0
local integer j
local integer sum = 0
loop
set sub = SubString(str,i,i + 1)
if(sub != ",")then
set j = 0
loop
if(sub == SubString(StringMap,j,j + 1))then
set sum = sum * 256 + j + 48
exitwhen true
endif
set j = j + 1
exitwhen j > 74
endloop
endif
set i = i + 1
exitwhen i > 3
endloop
return sum
endfunction
function Id2String takes integer id returns string
local string str = ""
local integer index
loop
exitwhen id <= 0
set index = id - id / 256 * 256
set str = SubString(StringMap,index - 48,index - 47) + str
set id = id / 256
endloop
return str
endfunction[/jass]
最实在的其实是这个: |
|