디비 sql파일에서 문자 내용이 hex로 표시되어서 만들었다. 젠장..
hex타입의 내용을 ''를 붙여 문자 그대로 저장하게 하려고 만든 스크립트다.

<?php
header("Content-Type: text/plain; charset=UTF-8");
//header("Content-Type: text/html; charset=UTF-8");

$filename = "./aa.sql";

function getStrAndReplace()
{
	global $filename;
	$fp = fopen($filename, "r") or die('open error');
	$fread = fread($fp, 90000000);
	$pattern = '/0x[a-z|0-9]*/i';
	$replacement = '\'\0\'';
	$str = preg_replace($pattern, $replacement, $fread, -1);
	fclose($fp);
	return $str;
}

function writeFile($str)
{
	global $filename;
	$fp = fopen($filename, "w") or die('open error');
	fwrite($fp, $str);
	fclose($fp);
}

//writeFile(getStrAndReplace()); // 파일로 저장(원본파일을 저장해버리니 주의!)
echo getStrAndReplace(); // 바뀐 내용을 출력
?>

메타데이터

조회수
809
좋아요
0

0개의 댓글

등록된 댓글이 없습니다.