Created
March 1, 2011 09:29
-
-
Save CrBoy/848895 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a funny tool to encode a UTF-8 file to only ascii charactors. | |
Therefore we can write C code by Chinese with some definition. | |
Issues: | |
In the Makefile, I'd like to create a automatical building, | |
but I forget how to use variables to indicate the names. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define _E695B4_E695B8 int | |
#define _E5AD97_E58583 char | |
#define _E5B8B8_E695B8 const | |
#define _E59B9E_E582B3 return | |
#define _E4B8BB_E8A681 main | |
#define _E58DB0_E587BA printf | |
_E695B4_E695B8 _E4B8BB_E8A681(_E695B4_E695B8 argc, _E5B8B8_E695B8 _E5AD97_E58583 *argv[]) | |
{ | |
_E695B4_E695B8 _E8AE8A_E695B81 = 12; | |
_E58DB0_E587BA("%d\n", _E58AA01(_E8AE8A_E695B81)); | |
_E59B9E_E582B3 0; | |
} | |
_E695B4_E695B8 _E58AA01(_E695B4_E695B8 _E794B2) | |
{ | |
_E59B9E_E582B3 _E794B2+1; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int leading_ones(unsigned char c); | |
void print_hex(unsigned char c); | |
int main(int argc, const char *argv[]) | |
{ | |
unsigned char c; | |
int count; | |
while(scanf("%c", &c)!=EOF){ | |
count = leading_ones(c); | |
if(count==0){ | |
fputc(c, stdout); | |
}else if(count==1){ | |
fputc(c, stdout); | |
}else{ | |
fputc('_', stdout); | |
print_hex(c); | |
while(--count){ | |
scanf("%c", &c); | |
print_hex(c); | |
} | |
} | |
} | |
return 0; | |
} | |
int leading_ones(unsigned char c) | |
{ | |
unsigned mask = 0x80; | |
int count = 0; | |
while(mask & c) | |
mask >>= 1, ++count; | |
return count; | |
} | |
void print_hex(unsigned char c) | |
{ | |
static char hnum[17]="0123456789ABCDEF"; | |
fputc(hnum[c>>4], stdout); | |
fputc(hnum[c&0x0f], stdout); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define 整數 int | |
#define 字元 char | |
#define 常數 const | |
#define 回傳 return | |
#define 主要 main | |
#define 印出 printf | |
整數 主要(整數 argc, 常數 字元 *argv[]) | |
{ | |
整數 變數1 = 12; | |
印出("%d\n", 加1(變數1)); | |
回傳 0; | |
} | |
整數 加1(整數 甲) | |
{ | |
回傳 甲+1; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
encoding_utf8: encoding_utf8.c | |
gcc -o encoding_utf8 encoding_utf8.c | |
# I forget how to use variables....orz | |
#enc-$.c: encoding_utf8 $.c | |
# ./encoding_utf8 <$.c >enc-$.c | |
# | |
#$: enc-$.c | |
# gcc -o $ enc-$.c | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
少了一行,
整數 加1(整數 那個數字);