diff --git a/nasal.h b/nasal.h index 8aa5201..139c395 100644 --- a/nasal.h +++ b/nasal.h @@ -114,6 +114,18 @@ std::string rawstr(const std::string& str) { std::string ret(""); for(auto i:str) + { +#ifdef _WIN32 + // windows ps or cmd doesn't output unicode normally + // if 'chcp65001' is not enabled, so we output the hex + if(i<=0) + { + ret+="\\x"; + ret+="0123456789abcdef"[(i>>4)&15]; + ret+="0123456789abcdef"[i&15]; + continue; + } +#endif switch(i) { case '\a': ret+="\\a";break; @@ -127,6 +139,7 @@ std::string rawstr(const std::string& str) case '\0': ret+="\\0";break; default: ret+=i; break; } + } return ret; } #include "nasal_err.h" diff --git a/test/qrcode.nas b/test/qrcode.nas new file mode 100644 index 0000000..868abf8 --- /dev/null +++ b/test/qrcode.nas @@ -0,0 +1,65 @@ +import("lib.nas"); + +var code=[ + [1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1], + [1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1], + [1,0,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1,0,1], + [1,0,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1,0,1], + [1,0,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1,0,1], + [1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1], + [1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1], + [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0], + [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], +]; + +if(os.platform()=="windows") + system("chcp 65001"); +var texture=[" ","██"]; +for(var i=0;i=0;i-=1){ + vec[i]=bits.bitand(1,len); + len=int(len/2); + } + println(vec); + + var bitstr=[]; + for(var i=0;i=0;j-=1){ + tmp[j]=bits.bitand(1,c); + c=int(c/2); + } + foreach(var j;tmp) + append(bitstr,j); + } + println(bitstr); + + var end=[0,0,0,0]; + println(end); +} + +transfer("github.com/ValKmjolnir"); \ No newline at end of file diff --git a/test/snake.nas b/test/snake.nas index 3254c30..8e0e3d4 100644 --- a/test/snake.nas +++ b/test/snake.nas @@ -78,6 +78,7 @@ var game=func(x,y){ } edge0~="╗\n"; edge1~="╝\n"; + var vec=[]; setsize(vec,x); for(var i=0;i=0){ + }elsif(move=='a' and fx-1>=0){ snake.push_front([fx-1,fy]); if(vec[fx-1][fy]==1) gameover=1; - else if(vec[fx-1][fy]==2) + elsif(vec[fx-1][fy]==2) eat=1; vec[fx-1][fy]=1; - }else if(move=='s' and fy+1