由于nfo文件的特殊性,需要特殊的字体或编码才能够正常显示。如果你用计事本查看,ascii码大于127的字符是乱码一堆。有没有办法用记事本来查看nfo呢?
看到ibic原创的nfo2txt (C语言版),我根据他的映射表做了这个php小程序。将nfo转换成unicode文本文件,外观基本一样。
需要设置一下记事本的字体为courier new或其他等宽字体才能正常查看。
演示: http://0day.ugia.net/program/nfo2pic/nfo2txt.php
- <?php
- /**
- * NFO TO TEXT (php version)
- *
- * Special thanks to ibic@9down
- * @author legend(PASiOcn@msn.com)
- */
- $conv_table = array(
- /* 0*/ 0x263a, 0x263b, 0x2665, 0x2666, 0x2663,
- /* 5*/ 0x2660, 0x25cf, 0x25d8, 0x2642, 0x2640,
- /* 10*/ 0x0000, 0x263c, 0x25ba, 0x0000, 0x2195,
- /* 15*/ 0x203c, 0x00b6, 0x00a7, 0x00f5, 0x21a8,
- /* 20*/ 0x2191, 0x2193, 0x2192, 0x2190, 0x221f,
- /* 25*/ 0x2194, 0x25b2, 0x25bc, 0x0000, 0x0000,
- /* 30*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 35*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 40*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 45*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 50*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 55*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 60*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 65*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 70*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 75*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 80*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 85*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 90*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /* 95*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*100*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*105*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*110*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*115*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*120*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*125*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*130*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*135*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*140*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*145*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*150*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*155*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*160*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*165*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*170*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*175*/ 0x0000, 0x2591, 0x2592, 0x2593, 0x2502,
- /*180*/ 0x2524, 0x2561, 0x2562, 0x2556, 0x2555,
- /*185*/ 0x2563, 0x2551, 0x2557, 0x255d, 0x255c,
- /*190*/ 0x255b, 0x2510, 0x2514, 0x2534, 0x252c,
- /*195*/ 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
- /*200*/ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560,
- /*205*/ 0x2550, 0x256c, 0x2567, 0x2568, 0x2564,
- /*210*/ 0x2565, 0x2559, 0x2558, 0x2552, 0x2553,
- /*215*/ 0x256a, 0x256a, 0x2518, 0x250c, 0x2588,
- /*220*/ 0x2584, 0x258c, 0x2590, 0x2580, 0x03b1,
- /*225*/ 0x03b2, 0x0000, 0x0000, 0x0000, 0x0000,
- /*230*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*235*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*240*/ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- /*245*/ 0x0000, 0x0000, 0x0000, 0x25cb, 0x2014,
- /*250*/ 0x2013, 0x0000, 0x0000, 0x0000, 0x25a0,
- /*255*/ 0x0000,
- );
- if(is_uploaded_file($_FILES['filename']['tmp_name']))
- {
- $fname = $_FILES['filename']['name'].".txt";
- $str = file_get_contents($_FILES['filename']['tmp_name']);
- $txt = conv_nfo($str);
- header('Content-type: application/x-octet-stream');
- header('Content-disposition: attachment; filename=' . $fname);
- print $txt;
- }
- else
- {
- echo "<html><head><style type='text/css'>body,input{font-size:11px;font-family:tahoma}</style></head><body>";
- echo "<form action='' method='post' enctype='multipart/form-data'>/n";
- echo "<input type='file' name='filename' size='50′ />";
- echo "<input type='submit' value='GET TXT' />";
- echo "</form>";
- echo "</body>";
- }
- //cove str
- function conv_nfo($str)
- {
- global $conv_table;
- for($i = 0; $i < strlen($str); $i ++)
- {
- if($conv_table[ord($str[$i])] == 0)
- {
- $output .= code2utf(ord($str[$i]));
- }
- else
- {
- $output .= code2utf($conv_table[ord($str[$i])]);
- }
- }
- return $output;
- }
- //code 2 unicode
- function code2utf($num)
- {
- if($num<128)
- return chr($num);
- if($num<1024)
- return chr(($num>>6)+192).chr(($num&63)+128);
- if($num<32768)
- return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
- if($num<2097152)
- return chr($num>>18+240).chr((($num>>12)&63)+128).chr(($num>>6)&63+128). chr($num&63+128);
- return '';
- }
- ?>
效果:
转载 上传了这个图片附件: