标题: 文本显示、行显、日志跟随监控工具TL.EXE [打印本页]
作者: happy886rr 时间: 2016-10-19 23:17 标题: 文本显示、行显、日志跟随监控工具TL.EXE
本帖最后由 happy886rr 于 2016-10-20 20:13 编辑
[Version2.0]修复7个漏洞,优化CPU占用率到3%以下,修复fgetws统计行数问题,增加强制跟随模式直接用-d开关无参数即可以进入。完全取代more、type、tail的强悍工具,支持数GB乃至TB级的超大文本,瞬间读取任意位置。代码继续精简了20行。可执行文件体积仅12KB。
下载地址:把下面图片存为a.zip解压即是。
具体用法:- TL.EXE
- __________________________________________________________________________
- 完全取代more、type、tail的强悍工具,采用64位流指针,支持数GB的超大文本,
- 瞬间读取任意位置。
-
- 智能识别文本编码,支持定义添加任意国编码识别框架,自动判断BOM类型。原生支持
- ANSI、UTF8、Unicode、Unicode big endian、BIG5台湾编码。准确识别有无BOM类型、
- 可自定义行长、编码检测阈、跟随阈。
-
- 支持按行读取、按百分比读取。瞬移指针,无等待。 实时侦测文件末端最新行的改变,
- 最大可支持数TB巨型日志。时间仓促,仅在WIN7企业版32位下测试,其它系统请自行
- 测试、酌情试配。
- __________________________________________________________________________
-
- 文本显示、行显、日志跟随监控工具, 版本 2.0
- COPYRIGHT@2016~2018 BY HAPPY
- 使用:
- tl [file] [-n&num1,num2]|[-p&per1,per2]|[-i]|[-d&num]
- __________________________________________________________________________
- 选项:
- -h 显示帮助信息
- -n 读取第num1行到第num2行的内容
- -p 按百分比读取文件内容从per1到per2,注:取值为[0,1]内的小数
- -i 显示文本的行数、文件大小
- -d 侦测文件的最新num行,静态显示
- -d 无参数则采取强制跟随策略,即毫秒跟随,动态显示
- 空 无开关则读取整个文件,支持7种编码
- __________________________________________________________________________
- 示例:
- tl a.txt //显示a.txt文本内容;
- tl a.txt -i //显示a.txt行数及文件大小;
- tl a.txt -n3 //从第3行读到结尾;
- tl a.txt -n3,5 //从第3行读到第5行;
- tl a.txt -p0.618,0.798 //显示文件的百分之几的内容
- tl a.txt -d15 //侦测文件最新15行的变动,按Q键中断
- tl a.txt -d //强制跟随文件变动,毫秒级响应
- __________________________________________________________________________
复制代码
核心代码:- /*
- DISPLAYS THE CONTENTS OF A TEXT FILE, VERSION 2.0
- COPYRIGHT@2016~2018 BY HAPPY
- */
- #include <stdio.h>
- #include <conio.h>
- #include <locale.h>
- #include <stdbool.h>
- #include <time.h>
- #include <windows.h>
-
-
-
- //定义标准行长(字节)
- #define BUFF_SIZE 4096
- //编码检测阈值(字节)
- #define CHECK_SIZE 16383
- //文件跟随阈值(行)
- #define FOLLOW_SIZE 1000
- //强制跟随行数(行)
- #define FOLLOW_LINE 3
- //跟随等待计时(毫秒)
- #define FOLLOW_WAIT 20
-
- /***************转码函数群***************/
- //Unicode 转Ansi
- char* UnicodeToANSI(const wchar_t* Str)
- {
- int L=WideCharToMultiByte(CP_ACP, 0, Str, -1, NULL, 0, NULL, NULL);
- char* Out=(char *)calloc(L+1, sizeof(char));
- WideCharToMultiByte(CP_ACP, 0, Str, -1, Out, L, NULL, NULL);
- return Out;
- }
- //UTF8 转换成 Unicode
- wchar_t* UTF8ToUnicode(const char* Str)
- {
- int L=MultiByteToWideChar(CP_UTF8, 0, Str,-1, NULL, 0);
- wchar_t* Out=(wchar_t *)calloc(L+1, sizeof(wchar_t));
- MultiByteToWideChar(CP_UTF8, 0, Str, -1, (LPWSTR)Out, L);
- return Out;
- }
- //BIG5 转换成 Unicode
- wchar_t* BIG5ToUnicode(const char* Str)
- {
- int L=MultiByteToWideChar(950, 0, Str,-1, NULL, 0);
- wchar_t* Out=(wchar_t *)calloc(L+1, sizeof(wchar_t));
- MultiByteToWideChar(950, 0, Str, -1, (LPWSTR)Out, L);
- return Out;
- }
-
- /***************编码检测群***************/
- //判断utf8无BOM
- bool isUTF8(const char* Str)
- {
- if(!Str){
- return false;
- }
- const unsigned char* bytes=(const unsigned char *)Str;
- while(*bytes){
- if(
- (
- bytes[0]<=0x7F ||
- bytes[0]==0x09 ||
- bytes[0]==0x0A ||
- bytes[0]==0x0D ||
- (0x20<=bytes[0] && bytes[0]<=0x7E)
- )
- ){
- bytes+=1;
- continue;
- }
- if(
- (
- (0xC2<=bytes[0] && bytes[0]<=0xDF) &&
- (0x80<=bytes[1] && bytes[1]<=0xBF)
- )
- ){
- bytes+=2;
- continue;
- }
- if(
- (
- (bytes[0]==0xE0) &&
- (0xA0<=bytes[1] && bytes[1]<=0xBF) &&
- (0x80<=bytes[2] && bytes[2]<=0xBF)
- ) ||
- (
- (
- (0xE1<=bytes[0] && bytes[0]<=0xEC)||
- bytes[0]==0xEE ||
- bytes[0]==0xEF
- ) &&
- (0x80<=bytes[1] && bytes[1]<=0xBF) &&
- (0x80<=bytes[2] && bytes[2]<=0xBF)
- ) ||
- (
- (bytes[0]==0xED) &&
- (0x80<=bytes[1] && bytes[1]<=0x9F) &&
- (0x80<=bytes[2] && bytes[2]<=0xBF)
- )
- ){
- bytes+=3;
- continue;
- }
- if(
- (
- (bytes[0]==0xF0) &&
- (0x90<=bytes[1] && bytes[1]<=0xBF) &&
- (0x80<=bytes[2] && bytes[2]<=0xBF) &&
- (0x80<=bytes[3] && bytes[3]<=0xBF)
- ) ||
- (
- (0xF1<=bytes[0] && bytes[0]<=0xF3) &&
- (0x80<=bytes[1] && bytes[1]<=0xBF) &&
- (0x80<=bytes[2] && bytes[2]<=0xBF) &&
- (0x80<=bytes[3] && bytes[3]<=0xBF)
- ) ||
- (
- (bytes[0]==0xF4) &&
- (0x80<=bytes[1] && bytes[1]<=0x8F) &&
- (0x80<=bytes[2] && bytes[2]<=0xBF) &&
- (0x80<=bytes[3] && bytes[3]<=0xBF)
- )
- ){
- bytes+=4;
- continue;
- }
- return false;
- }
- return true;
- }
- //判断GB2312
- bool isGB2312(const char* Str)
- {
- if(!Str){
- return false;
- }
- const unsigned char* bytes=(const unsigned char *)Str;
- while(*bytes){
- if(
- (
- bytes[0]<=0x7F ||
- bytes[0]==0x09 ||
- bytes[0]==0x0A ||
- bytes[0]==0x0D ||
- (0x20<=bytes[0] && bytes[0]<=0x7E)
- )
- ){
- bytes+=1;
- continue;
- }
- if(
- (0xA1<=bytes[0] && bytes[0]<=0xF7) &&
- (0xA1<=bytes[1] && bytes[1]<=0xFE)
- ){
- bytes+=2;
- continue;
- }
- return false;
- }
- return true;
- }
- /*判断BIG5*/
- bool isBIG5(const char* Str)
- {
- if(!Str){
- return false;
- }
- const unsigned char* bytes=(const unsigned char *)Str;
- while(*bytes){
- if(
- (
- bytes[0]<=0x7F ||
- bytes[0]==0x09 ||
- bytes[0]==0x0A ||
- bytes[0]==0x0D ||
- (0x20<=bytes[0] && bytes[0]<=0x7E)
- )
- ){
- bytes+=1;
- continue;
- }
- if(
- (0xA1<=bytes[0] && bytes[0]<=0xF9) &&
- (
- (0x40<=bytes[1] && bytes[1]<=0x7E) ||
- (0xA1<=bytes[1] && bytes[1]<=0xFE)
- )
- ){
- bytes+=2;
- continue;
- }
- return false;
- }
- return true;
- }
- //判断文件BOM
- int CheckBom(FILE* fp)
- {
- unsigned char* buf=(unsigned char*)calloc(3,sizeof(unsigned char));
- unsigned char* buf2;
- fseeko64(fp, (__int64)0, SEEK_SET);
- fread(buf, sizeof(unsigned char), 3, fp);
- if(buf[0]==0xEF && buf[1]==0xBB && buf[2]==0xBF){return 3;}
- else if(buf[0]==0xFF && buf[1]==0xFE){return 5;}
- else if(buf[0]==0xFE && buf[1]==0xFF){return 6;}
- else{
- fseeko64(fp, (__int64)0, SEEK_SET);
- buf2=(unsigned char*)calloc(CHECK_SIZE,sizeof(unsigned char));
- fread(buf2, sizeof(unsigned char), CHECK_SIZE, fp);
- if(isUTF8(buf2)){
- return 2;
- }else if(isGB2312(buf2)){
- return 1;
- }else if(isBIG5(buf2)){
- return 4;
- }
- }
- return 1;
- }
-
- /***************功能函数群***************/
- //帮助信息
- void Help_Information(FILE* stream, int Exit_Code)
- {
- fprintf(stream,
- ">>>------------------------------------------------------------\n"
- "DISPLAYS THE CONTENTS OF A TEXT FILE\n"
- "VERSION 2.0\n"
- "tl [file] [-n&num1,num2]|[-p&per1,per2]|[-i]|[-d&num]\n"
- "---------------------------------------------------------------\n\n"
- " -h Show help information\n"
- " -n Read lines from num1 to num2\n"
- " -p Read lines from percent1 to percent2\n"
- " -i Show file's information\n"
- " -d Detection latest num lines \n"
- "------------------------------------------------------------<<<\n"
- " 10/19/2016\n"
- );
- exit(Exit_Code);
- }
- //按键函数
- int Getkey(int N,int T)
- {
- int i,KEY_V,start=clock();
- do{
- if(kbhit()){
- KEY_V=(int)(getch());
- if(KEY_V<97){KEY_V+=32;}
- return KEY_V;
- }
- for(i=0;i<=N;i++);
- }while((clock()-start)<T);
- return -1;
- }
- //行数统计
- int CountLines(FILE* fp)
- {
- int i=0;
- char* line=(char *)malloc(BUFF_SIZE*sizeof(char));
- while(!feof(fp)){
- fgets(line, BUFF_SIZE, fp);
- i++;
- }
- return i;
- }
- //文件信息
- void File_Information(FILE* fp, char* fname)
- {
- fseeko64(fp, (__int64)0, SEEK_END);
- __int64 fsize=ftello64(fp);
- fseeko64(fp, (__int64)0, SEEK_SET);
- int linenum=CountLines(fp);
- fprintf(stdout,
- "FILE NAME : %s\n"
- "FILE SIZE : %I64d\n"
- "FILE LINES: %d\n"
- ,fname, fsize, linenum
- );
- }
- //行显函数
- int DisplayLine(FILE* fp, int flag, int N1, int N2, __int64 F1, __int64 F2)
- {
- int i=0, n=0, BOM=0, EN=0;
- //设定BOM偏移值
- BOM=CheckBom(fp);
- if(BOM==1 || BOM==2 || BOM==4){
- EN=0;
- }else if(BOM==5 || BOM==6){
- EN=2;
- }else if(BOM==3){
- EN=3;
- }
- //设定模式偏移量
- if (flag==0){
- fseeko64(fp, (__int64)EN, SEEK_SET);
- }else if(flag==1||flag==3){
- __int64 FD=(N1*BUFF_SIZE>F2)?F2:N1*BUFF_SIZE;
- fseeko64(fp, -FD, SEEK_END);
- N1=CountLines(fp)-N1+1;
- fseeko64(fp, -FD, SEEK_END);
- }else if(flag==2){
- fseeko64(fp, F1, SEEK_SET);
- }
- if(BOM<5){
- char* Line=(char *)malloc(BUFF_SIZE*sizeof(char));
- while(!feof(fp)||flag==3){
- memset(Line, 0, BUFF_SIZE*sizeof(char));
- if(!fgets(Line, BUFF_SIZE, fp)){Sleep(1);}
- i++;
- if( ((N1<=i) && (i<=N2) && (F1<=ftello64(fp)) && (ftello64(fp)<=F2))||(flag==3) ){
- switch(BOM){
- case 1: //Ansi行显
- fputs(Line, stdout);
- break;
- case 2: //Utf8无BOM行显
- case 3: //Utf8行显
- fputs(UnicodeToANSI(UTF8ToUnicode(Line)), stdout);
- break;
- case 4: //Big5行显
- fputs(UnicodeToANSI(BIG5ToUnicode(Line)), stdout);
- break;
- }
- }else if((i>N2) && (ftello64(fp)>=F2)){
- break;
- }
- }
- }else if(BOM==5){ //Unicode行显
- wchar_t* LineW=(wchar_t *)calloc(BUFF_SIZE, sizeof(wchar_t));
- while(!feof(fp)||(flag==3)){
- memset(LineW, 0, BUFF_SIZE*sizeof(wchar_t));
- if(!fgetws(LineW, BUFF_SIZE, fp)){Sleep(1);}
- i++;
- if( ((N1<=i) && (i<=N2) && (F1<=ftello64(fp)) && (ftello64(fp)<=F2))||(flag==3) ){
- fputs(UnicodeToANSI(LineW), stdout);
- }else if((i>N2) && (ftello64(fp)>=F2)){
- break;
- }
- }
- }else if(BOM==6){ //Unicode big endian行显
- wchar_t* LineW=(wchar_t *)calloc(BUFF_SIZE, sizeof(wchar_t));
- while(!feof(fp)||(flag==3)){
- memset(LineW, 0, BUFF_SIZE*sizeof(wchar_t));
- if(!fgets(LineW, BUFF_SIZE, fp)){Sleep(1);}
- i++;
- if( ((N1<=i) && (i<=N2+1) && (F1<=ftello64(fp)) && (ftello64(fp)<=F2))||(flag==3) ){
- for(n=0;LineW[n]!=0x0000;n++){
- LineW[n]=(LineW[n]&0x00FF)<<8|(LineW[n]&0xFF00)>>8;
- }
- fputs(UnicodeToANSI(LineW), stdout);
- }else if((i>N2) && (ftello64(fp)>=F2)){
- break;
- }
- }
- }
- fflush(stdout);
- return 0;
- }
-
- /*************MAIN主函数入口*************/
- int main(int argc, char** argv)
- {
- int N1=1, N2=2147483631, FLAG=0, i;
- __int64 fsize=0;
- float P1=0.0, P2=1.0;
- FILE* fp;
- char* delims;
- if((argc==3) && (argv[2][0]=='-')){
- switch(argv[2][1]){
- case 'H':
- case 'h':
- Help_Information(stdout, 0);
- case 'N':
- case 'n':
- delims=(argv[2]+2);
- N1=atoi(strtok(delims, ","));
- N2=atoi(strtok(NULL, ","));
- if(N2==0){N2=2147483631;}
- if((N1>N2) || (N1<0) || (N2<0)){Help_Information(stderr, 1);}
- break;
- case 'P':
- case 'p':
- delims=(argv[2]+2);
- P1=atof(strtok(delims, ","));
- P2=atof(strtok(NULL, ","));
- if((P1>=P2) || (P1>1.0) || (P2>1.0) || (P1<0.0) || (P2<0.0) ){Help_Information(stderr, 1);}
- FLAG=2;
- break;
- case 'I':
- case 'i':
- if( (fp=fopen64(argv[1], "rb"))==NULL ){fputs("Read failed.", stdout);return 3;}
- File_Information(fp, argv[1]);
- fclose(fp);
- return 0;
- case 'D':
- case 'd':
- delims=(argv[2]+2);
- N1=abs(atoi(delims)), N1=(N1>FOLLOW_SIZE)?1000:N1, FLAG=1;
- if(argv[2][2]=='\0'){N1=FOLLOW_LINE,FLAG=3;}
- break;
- default:
- Help_Information(stderr, 2);
- }
- }else if(argc!=2){
- Help_Information(stderr, 3);
- }
- if( (fp=fopen64(argv[1], "rb"))==NULL ){
- fputs("Read failed.", stdout);
- return 3;
- }
- if(FLAG==1){
-
- do{
- fseeko64(fp, (__int64)0, SEEK_END);
- if( fsize!=ftello64(fp)){
- fsize =ftello64(fp);
- system("cls");
- DisplayLine(fp, 1, N1, 2147483631, 0, fsize);
- }
- }while(Getkey(64,FOLLOW_WAIT)!=113);
- fputs("\n", stdout);
- fclose(fp);
- return 0;
- }
- fseeko64(fp, (__int64)0, SEEK_END);
- fsize=ftello64(fp);
- DisplayLine(fp, FLAG, N1, N2, fsize*P1, fsize*P2);
- fclose(fp);
- return 0;
- }
复制代码
_____________
_____________
______________________________________________________________________________________________________________
同时发布tl的精简版minitl仅3KB大小,迷你版minitl只支持utf8和ansi编码,速度快,支持取负行,是more和type的替代品。
minitl的用法:
提取文本文件filename的第n行到第m行复制代码
只提取第n行复制代码
提取倒数第3行复制代码
提取第5行到文件结束复制代码
base64加权压缩码。- @echo off
- ::******Happy's 文本工具 minitl.exe******
- set "LINE=TVqQ[M]E]//8[Lg{AQ_{][Ag]A4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJ{ABQRQ[TAEC}AO[DwMLAQY}AYBU]Q]I]AB]Q]Ag[B{[E{[Aw]Ag[NQwB[M][B[AB][E[AE{B{][ACAg[A8$_{][BcI[AX_]C50ZXh0]UAc]Q]C]AI}[C[AGAuZGF0YQ[ACAC]I]AQ]K}[B[AD${[ABVieWB7Ag[ACQu]ABQu]ABQu]ABQu]ABQuP////9Qi0UIULg]AULg]AUOhzBg[iUX4i0X4QLkB]UVDoaAY[IPECIlF/Lg]AULg]AUItF+FCLRfxQuP////9Qi0UIULg]AULg]AUOgrBg[i0X86Q]DJw1WJ5YHsC]JC4]AFC4]AFC4/////1CLRQhQu]ABQuOn9[BQ6[G[CJRfyLRfxAuQI[ABRUOjlBQ[g8QIiUX4i0X8UItF+FC4/////1CLRQhQu]ABQuOn9[BQ6MQF[CLRfjp]AMnDVYnlgewI]kLg]AiUX8u]ABQi0UYUItFCFDonQU[IPEDItFCFDomQU[IPEBIXAD4QF]6dg[AC4AQ[AFC4AB[AFDoYAU[IPECIlF+ItFCFC4AB[AFCLRfhQ6GcF[CDxAyFwA+Eng[AItF/InBQIlF/ItFDIXAD4QF]6YU[ACLRfyLTRA5yA+Mdw[AItF/ItNFDnID44K]uP/////pjQ[AItFGIXAD4QF]6Rs[ACLBXggQACDwCBQi0X4UOgCBQ[g8QI6TQ[ACLRRiD+AMPhSg[ACLRfhQ6JT+//+D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expansion
- set "Z=A"&(for %%Z in ([,],{,},_,$,#,-,@) do (set "Z=!Z!!Z!"&for %%S in (!Z!) do (set "LINE=!LINE:%%Z=%%S!")))&echo !LINE:.=!>base64_minitl
- certutil -decode base64_minitl minitl.exe
复制代码
作者: wskwfkbdn 时间: 2016-10-20 00:14
真牛 ~
作者: Spring 时间: 2016-10-20 14:41
4096把长行拆成几行了,classpath超出你相信
作者: CrLf 时间: 2016-10-20 18:12
卧槽,史上最快版本迭代
作者: yu2n 时间: 2016-10-20 21:01
- ::******Base64加权解密器*************
- setlocal enabledelayedexpansion
- set "Z=A"&(for %%Z in ([,],{,},_,$,#,-,@) do (set "Z=!Z!!Z!"&for %%S in (!Z!) do (set "LINE=!LINE:%%Z=%%S!")))&echo !LINE:.=!>base64_minitl
复制代码
压缩前 4780 个字符,压缩后 2859 个字符,压缩了 40.19% 。
这算法很好,可惜看不懂。
作者: happy886rr 时间: 2016-10-20 21:16
本帖最后由 happy886rr 于 2016-10-20 21:28 编辑
回复 5# yu2n
加权,谁的权重大,就优先压缩谁。层层嵌套,这只是一层,只压了40%,如果是3层,可以实现体积减少80%,不过得携带通用解压字典。类似过去的电报译码表。经过几次测试,这种算法的有点经常超越7Z的压缩率。要想压得狠,就得带字典。
比如论坛代码遇到g c d这几个组合就会被吃掉,所以可以把**定义为一个字母,总之给一些常用的组合编码,制作成码表,解压的时候根据码表重组。就好比基因工程,基因决定了你的生物性状,但基因只是压缩的编码,生物是由基因调度氨基酸组合成蛋白质构成细胞结构体。这也是仿生学。
作者: pcl_test 时间: 2016-10-20 22:13
回复 5# yu2n
可以想象成俄罗斯套娃
作者: CrLf 时间: 2016-10-20 23:08
本帖最后由 CrLf 于 2016-10-20 23:21 编辑
回复 6# happy886rr
效果很好,尤其是 EXE 的 Base64,但是目前只适用于 A,若要扩展到其他字符,如何区分不同的层?
作者: CrLf 时间: 2016-10-20 23:19
本帖最后由 CrLf 于 2016-10-20 23:34 编辑
附顶楼压缩代码:- @echo off
- REM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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
- setlocal enabledelayedexpansion
- set "Z=A"
- for %%Z in (@,-,#,$,_,},{,],[) do (
- for %%S in (!Z!) do (
- set "LINE=!LINE:%%S%%S=%%Z!"
- )
- set "Z=%%Z"
- )
- echo !LINE!
- pause
复制代码
作者: happy886rr 时间: 2016-10-21 07:38
回复 9# CrLf
小写aa会被干掉吗?
作者: CrLf 时间: 2016-10-21 12:23
回复 10# happy886rr
是哦,我怎么没想到
作者: wskwfkbdn 时间: 2016-10-24 07:12
TL的bug ,unicode 无BOM头识别失败
作者: happy886rr 时间: 2016-10-24 09:18
回复 12# wskwfkbdn
unicode和unicode big endian一般是靠bom来区分字节序的。如果没有bom,你可以直接在tl的C代码的编码检测群中添加一个函数,检测00 0A或0A 00。从而判断大小端。- /*判断大小端*/
- int isUnicode(const char* Str)
- {
- if(!Str){
- return false;
- }
- const unsigned char* bytes=(const unsigned char *)Str;
- while(*bytes){
- if(bytes[0]==0x00 && bytes[1]==0x0A){
- return 1; //小端
- }else if(bytes[0]==0x0A && bytes[1]==0x00){
- return 2; //大端
- }
- bytes+=2;
- }
- return 0; //除非这个文本一个换行符都没有
- }
复制代码
作者: 523066680 时间: 2016-10-24 09:43
本帖最后由 523066680 于 2016-10-24 10:03 编辑
回复 11# CrLf
《Why didn't I think of that》
作者: wskwfkbdn 时间: 2016-10-24 11:55
回复 13# happy886rr
0D 00 0A 00
如果没有呢,就不好判断了吧
作者: 523066680 时间: 2016-10-24 15:58
回复 15# wskwfkbdn
如果取样素材及其有限,我想一些主流文本编辑器也只能选择显示16进制码。用户得自己选择采用哪种编码浏览
作者: wskwfkbdn 时间: 2016-10-24 17:21
回复 16# 523066680
前面gbk,utf8,测试识别还是准确的,识别unicode编码也就不难了,如果先进程编码转换 unicode转gbk编码,以gbk方法识别正确则认定是unicode编码
作者: 523066680 时间: 2016-10-24 17:23
utf16-be utf16-le
其中有一些把字节反过来可以成为另一种编码解读的对应字符,列出一些常见字符的部分- 0034 - 4, 3400 - 㐀
- 0035 - 5, 3500 - 㔀
- 0036 - 6, 3600 - 㘀
- 0037 - 7, 3700 - 㜀
- 0038 - 8, 3800 - 㠀
- 0039 - 9, 3900 - 㤀
- 003A - :, 3A00 - 㨀
- 003B - ;, 3B00 - 㬀
- 003C - <, 3C00 - 㰀
- 003D - =, 3D00 - 㴀
- 003E - >, 3E00 - 㸀
- 003F - ?, 3F00 - 㼀
- 0040 - @, 4000 - 䀀
- 0041 - A, 4100 - 䄀
- 0042 - B, 4200 - 䈀
- 0043 - C, 4300 - 䌀
- 0044 - D, 4400 - 䐀
- 0045 - E, 4500 - 䔀
- 0046 - F, 4600 - 䘀
- 0047 - G, 4700 - 䜀
- 0048 - H, 4800 - 䠀
- 0049 - I, 4900 - 䤀
- 004A - J, 4A00 - 䨀
- 004B - K, 4B00 - 䬀
- 004C - L, 4C00 - 䰀
- 004D - M, 4D00 - 䴀
- 004E - N, 4E00 - 一
- 004F - O, 4F00 - 伀
- 0050 - P, 5000 - 倀
- 0051 - Q, 5100 - 儀
- 0052 - R, 5200 - 刀
- 0053 - S, 5300 - 匀
- 0054 - T, 5400 - 吀
- 0055 - U, 5500 - 唀
- 0056 - V, 5600 - 嘀
- 0057 - W, 5700 - 圀
- 0058 - X, 5800 - 堀
- 0059 - Y, 5900 - 夀
- 005A - Z, 5A00 - 娀
- 005B - [, 5B00 - 嬀
- 005C - \, 5C00 - 尀
- 005D - ], 5D00 - 崀
- 005E - ^, 5E00 - 帀
- 005F - _, 5F00 - 开
- 0060 - `, 6000 - 怀
- 0061 - a, 6100 - 愀
- 0062 - b, 6200 - 戀
- 0063 - c, 6300 - 挀
- 0064 - d, 6400 - 搀
- 0065 - e, 6500 - 攀
- 0066 - f, 6600 - 昀
- 0067 - g, 6700 - 最
- 0068 - h, 6800 - 栀
- 0069 - i, 6900 - 椀
- 006A - j, 6A00 - 樀
- 006B - k, 6B00 - 欀
- 006C - l, 6C00 - 氀
- 006D - m, 6D00 - 洀
- 006E - n, 6E00 - 渀
- 006F - o, 6F00 - 漀
- 0070 - p, 7000 - 瀀
- 0071 - q, 7100 - 焀
- 0072 - r, 7200 - 爀
- 0073 - s, 7300 - 猀
- 0074 - t, 7400 - 琀
- 0075 - u, 7500 - 甀
- 0076 - v, 7600 - 瘀
- 0077 - w, 7700 - 眀
- 0078 - x, 7800 - 砀
- 0079 - y, 7900 - 礀
- 007A - z, 7A00 - 稀
- 007B - {, 7B00 - 笀
- 007C - |, 7C00 - 簀
- 007D - }, 7D00 - 紀
复制代码
[attach]10209[/attach] 附件
附件用sublime text打开,默认显示16进制码,可以手动用utf-16le格式查看,也可以用utf-16be格式查看,文字显示是反过来的
不过好在 000d 和 000a 就没有这个调换字节后相当于另一个常见字符的问题,而且本身比较常见,无BOM的情况下,我觉得以此为判断已经是比较好的办法。
作者: 523066680 时间: 2016-10-24 20:15
本帖最后由 523066680 于 2016-10-24 20:16 编辑
再来一点,同样的字节值,可以按不同编码解读为不同的汉字/偏僻字- gbk:
- 鵃鵄鵅鵆鵇鵈鵉鵊鵋鵌鵍鵎鵏鵑鵒鵓鵔鵕鵖鵗鵘鵙鵚鵛鵜鵝鵞鵟鵠鵡鵢鵣鵤鵥鵦鵧鵨鵩鵪鵫鵬鵭鵮鵯鵰鵱鵲鵳鵴鵵鵶鵷鵸鵹鵺鵻鵼鵽鵾鵿鶀鶁
-
- utf16-le:
- 䃹䇹䋹䏹䓹䗹䛹䟹䣹䧹䫹䯹䳹仹俹價凹勹叹哹嗹囹培壹姹嫹对峹巹廹忹惹懹拹揹擹旹曹柹棹槹櫹毹泹淹滹濹烹燹狹珹瓹痹盹矹磹秹竹篹糹緹绹
-
- utf16-be:
- 鹿論壟弄籠聾牢磊賂雷壘屢樓漏累縷陋勒肋凜凌稜綾菱陵讀拏樂諾丹寧怒率異北磻便復不泌數索參塞省葉說殺辰沈拾若掠略亮兩凉梁糧良諒量
-
- big5:
- 纘纛纙臠臡虆虇虈襹襺襼襻觿讙躥躤躣鑮鑭鑯鑱鑳靉顲饟鱨鱮鱭鸋鸍鸐鸏鸒鸑麡黵鼉齇齸齻齺齹圞灦籯蠼趲躦釃鑴鑸鑶鑵驠鱴鱳鱱鱵鸔鸓黶鼊
复制代码
作者: wskwfkbdn 时间: 2016-10-24 20:37
回复 19# 523066680
真的好吗?这方法我实验过,效率慢且不同编码有些字符集是相同的,会误判。
作者: 523066680 时间: 2016-10-24 20:56
本帖最后由 523066680 于 2016-10-24 21:27 编辑
回复 20# wskwfkbdn
?我没有提供哪个方法,是觉得楼主以00 0d 或者 0d 00作为辨别是还可以的方案啊。
(就是说即使这个方法效率低,好吧,那不是我提出来的
然后从17楼看感觉可能频道不对,前面讨论 LE 和 BE 的辨别,为何涉及到GBK ?
前面gbk,utf8,测试识别还是准确的,识别unicode编码也就不难了,如果先进程编码转换 unicode转gbk编码,以gbk方法识别正确则认定是unicode编码
假设上面是在说LE 和 BE的辨别,我觉得,如果以转GBK再转unicode对比作为辨别,会有两个问题:
1. GBK的范围没有 UTF 这么广泛
2. 有些数据,既可以按大端序解读为Unicode再转GBK,也可以按小端序解读为Unicode再转GBK,他们看上去都是正常的字符或者汉字,这个时候怎么辨别LE 还是 BE?- use Encode;
-
- binmode(STDOUT, ":encoding(gbk)"); #输出时统一转为gbk
-
- print decode('gbk', "\xf9\x7a");
- print decode('utf16-le', "\xf9\x7a");
- print decode('utf16-be', "\xf9\x7a");
复制代码
输出
鵽竹梁
作者: wskwfkbdn 时间: 2016-10-24 21:41
本帖最后由 wskwfkbdn 于 2016-10-24 21:49 编辑
回复 21# 523066680
编码检测工具下载:图片另存为,改rar解压
作者: 523066680 时间: 2016-10-24 21:53
本帖最后由 523066680 于 2016-10-24 22:24 编辑
回复 22# wskwfkbdn
所以…… 这个工具是你写的,在LE 和 BE这件事情上,识别效率和准确率比通过 00 0d , d0 00; 00 0a / 0a 00辨别更高??
作者: wskwfkbdn 时间: 2016-10-24 22:32
回复 23# 523066680
对,忽略bom头识别,
作者: CrLf 时间: 2016-10-25 00:41
回复 24# wskwfkbdn
神器1:http://www.bathome.net/s/tool/index.html?key=enca
神器2:http://www.bathome.net/s/tool/index.html?key=file
或 mshta:- mshta http://bathome.net/s/hta/?string "t=iconv.load('a.html');list.charset().where(function(c){return iconv.toStr(t,c)})"|more
复制代码
http://www.bathome.net/viewthread.php?tid=39824
作者: wskwfkbdn 时间: 2016-10-25 06:21
先赞一个吧
作者: 523066680 时间: 2016-10-25 08:11
本帖最后由 523066680 于 2016-10-25 09:48 编辑
Perl和Python都是有直接的库可以检测,已经被脚本语言惯坏了,所以重看楼主C代码的时候觉得,良心制作。
不过,考虑到传入的文件名符号可能是Unicode的(比如拖放到终端),可以试试用 _tmain 或者 wmain
用了之后有些输入输出函数、参数要跟着加前缀
作者: CrLf 时间: 2016-10-26 02:43
本帖最后由 CrLf 于 2016-10-26 02:45 编辑
如果不考虑复杂度的话,该算法还可优化,例如:
AAAAAAAABBBBBBBBCDEBBBBBBBBCCCCAAAAAAAAAAAA
用顶楼算法得到的结果是:
# BBBBBBBB CDE BBBBBBBB CCCC #-
进一步压缩得到的结果是(规则参考附文):
# >B# CDE # >C- <#-
规则是在重复字符发生变化的节点前声明此后的重复字符,如多个重复字符串比邻,则仅需声明一次:
>B 此后的所有 @ - # $ _ } { ] [ 均表示特定个数的 B
>C 同上,表示特定个数的 C
< 同上,表示特定个数的 A(默认)
接下来可以再考虑如何处理重复的词
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |