Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. library Ascii initializer Init
  2.  
  3.     globals
  4.         private integer array Ints
  5.         private string  array Chars
  6.     endglobals
  7.    
  8.     function Char2Ascii takes string s returns integer
  9.         local integer i=Ints[StringHash(s)/0x1F0748+0x3EA]
  10.         if i==47 and s=="\\" then
  11.             seti=92
  12.         elseif i>=65 and i<=90 and s!=Chars[i] then
  13.             set i=i+32
  14.         endif
  15.         return i
  16.     endfunction
  17.  
  18.     function Ascii2Char takes integer i returns string
  19.         returnChars[i]
  20.     endfunction
  21.  
  22.     module AsciiInit
  23.         private static method onInit takes nothing returns nothing
  24.                 set Ints[931]=8
  25.                 set Ints[1075]=9
  26.                 set Ints[1586]=10
  27.                 set Ints[1340]=12
  28.                 set Ints[412]=13
  29.    
  30.                 set Ints[198]=32
  31.                 set Ints[1979]=33
  32.                 set Ints[1313]=34
  33.                 set Ints[1003]=35
  34.                 set Ints[1264]=36
  35.                 set Ints[983]=37
  36.                 set Ints[1277]=38
  37.                 set Ints[306]=39
  38.                 set Ints[904]=40
  39.                 set Ints[934]=41
  40.                 set Ints[917]=42
  41.                 set Ints[1972]=43
  42.                 set Ints[1380]=44
  43.                 set Ints[1985]=45
  44.                 set Ints[869]=46
  45.  
  46.                 set Ints[1906]=47
  47.  
  48.                 set Ints[883]=48
  49.                 set Ints[1558]=49
  50.                 set Ints[684]=50
  51.                 set Ints[582]=51
  52.                 set Ints[668]=52
  53.                 set Ints[538]=53
  54.                 set Ints[672]=54
  55.                 set Ints[1173]=55
  56.                 set Ints[71]=56
  57.                 set Ints[277]=57
  58.  
  59.                 set Ints[89]=58
  60.                 set Ints[1141]=59
  61.                 set Ints[39]=60
  62.                 set Ints[1171]=61
  63.                 set Ints[51]=62
  64.                 set Ints[305]=63
  65.                 set Ints[0]=64
  66.  
  67.                 set Ints[222]=65
  68.                 set Ints[178]=66
  69.                 set Ints[236]=67
  70.                 set Ints[184]=68
  71.                 set Ints[1295]=69
  72.                 set Ints[1390]=70
  73.                 set Ints[1276]=71
  74.                 set Ints[203]=72
  75.                 set Ints[1314]=73
  76.                 set Ints[209]=74
  77.                 set Ints[1315]=75
  78.                 set Ints[170]=76
  79.                 set Ints[1357]=77
  80.                 set Ints[1343]=78
  81.                 set Ints[1397]=79
  82.                 set Ints[1420]=80
  83.                 set Ints[1419]=81
  84.                 set Ints[1396]=82
  85.                 set Ints[1374]=83
  86.                 set Ints[1407]=84
  87.                 set Ints[499]=85
  88.                 set Ints[1465]=86
  89.                 set Ints[736]=87
  90.                 set Ints[289]=88
  91.                 set Ints[986]=89
  92.                 set Ints[38]=90
  93.  
  94.                 set Ints[1230]=91
  95.                 set Ints[1636]=93
  96.                 set Ints[1416]=94
  97.                 set Ints[1917]=95
  98.                 set Ints[217]=96
  99.                 set Ints[833]=123
  100.                 set Ints[1219]=124
  101.                 set Ints[553]=125
  102.                 set Ints[58]=126
  103.  
  104.                 set Chars[8]="\b"
  105.                 set Chars[9]="\t"
  106.                 set Chars[10]="\n"
  107.                 set Chars[12]="\f"
  108.                 set Chars[13]="\r"
  109.  
  110.                 set Chars[32]=""
  111.                 set Chars[33]="!"
  112.                 set Chars[34]="\""
  113.                 set Chars[35]="#"
  114.                 set Chars[36]="$"
  115.                 set Chars[37]="%"
  116.                 set Chars[38]="&"
  117.                 set Chars[39]="'"
  118.                 set Chars[40]="("
  119.                 set Chars[41]=")"
  120.                 set Chars[42]="*"
  121.                 set Chars[43]="+"
  122.                 set Chars[44]=","
  123.                 set Chars[45]="-"
  124.                 set Chars[46]="."
  125.  
  126.                 set Chars[47]="/"
  127.  
  128.                 set Chars[48]="0"
  129.                 set Chars[49]="1"
  130.                 set Chars[50]="2"
  131.                 set Chars[51]="3"
  132.                 set Chars[52]="4"
  133.                 set Chars[53]="5"
  134.                 set Chars[54]="6"
  135.                 set Chars[55]="7"
  136.                 set Chars[56]="8"
  137.                 set Chars[57]="9"
  138.  
  139.                 set Chars[58]=":"
  140.                 set Chars[59]=";"
  141.                 set Chars[60]="<"
  142.                 set Chars[61]="="
  143.                 set Chars[62]=">"
  144.                 set Chars[63]="?"
  145.                 set Chars[64]="@"
  146.  
  147.                 set Chars[65]="A"
  148.                 set Chars[66]="B"
  149.                 set Chars[67]="C"
  150.                 set Chars[68]="D"
  151.                 set Chars[69]="E"
  152.                 set Chars[70]="F"
  153.                 set Chars[71]="G"
  154.                 set Chars[72]="H"
  155.                 set Chars[73]="I"
  156.                 set Chars[74]="J"
  157.                 set Chars[75]="K"
  158.                 set Chars[76]="L"
  159.                 set Chars[77]="M"
  160.                 set Chars[78]="N"
  161.                 set Chars[79]="O"
  162.                 set Chars[80]="P"
  163.                 set Chars[81]="Q"
  164.                 set Chars[82]="R"
  165.                 set Chars[83]="S"
  166.                 set Chars[84]="T"
  167.                 set Chars[85]="U"
  168.                 set Chars[86]="V"
  169.                 set Chars[87]="W"
  170.                 set Chars[88]="X"
  171.                 set Chars[89]="Y"
  172.                 set Chars[90]="Z"
  173.  
  174.                 set Chars[92]="\\"
  175.  
  176.                 set Chars[97]="a"
  177.                 set Chars[98]="b"
  178.                 set Chars[99]="c"
  179.                 set Chars[100]="d"
  180.                 set Chars[101]="e"
  181.                 set Chars[102]="f"
  182.                 set Chars[103]="g"
  183.                 set Chars[104]="h"
  184.                 set Chars[105]="i"
  185.                 set Chars[106]="j"
  186.                 set Chars[107]="k"
  187.                 set Chars[108]="l"
  188.                 set Chars[109]="m"
  189.                 set Chars[110]="n"
  190.                 set Chars[111]="o"
  191.                 set Chars[112]="p"
  192.                 set Chars[113]="q"
  193.                 set Chars[114]="r"
  194.                 set Chars[115]="s"
  195.                 set Chars[116]="t"
  196.                 set Chars[117]="u"
  197.                 set Chars[118]="v"
  198.                 set Chars[119]="w"
  199.                 set Chars[120]="x"
  200.                 set Chars[121]="y"
  201.                 set Chars[122]="z"
  202.  
  203.                 set Chars[91]="["
  204.                 set Chars[93]="]"
  205.                 set Chars[94]="^"
  206.                 set Chars[95]="_"
  207.                 set Chars[96]="`"
  208.                 set Chars[123]="{"
  209.                 set Chars[124]="|"
  210.                 set Chars[125]="}"
  211.                 set Chars[126]="~"
  212.         endmethod
  213.     endmodule
  214.  
  215.     private struct ASCII extends array
  216.         import AsciiInit
  217.     endstruct
  218.  
  219. endlibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement