Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- 윈도우앱지우기
- winscp
- 아이티제어
- centos7
- 신바람여비서win98
- utf8mb4
- ubunto #네티워크설정
- 한글2 #hangul2_from_2024_01_17
- CenOS6.10
- PHP4
- windows19Server
- 에디트플러스 #sftp안될때
- PID4
- 인터넷안되는문제해결
- putty
- sftp
- MSSQL #TCP/IP Enabled
- ftp
- 코드라마 #AI
- 조성남
- root직접로그인
- IT제어
- php7
- CapsLock키보드 뽑기
Archives
- Today
- Total
아이티제어
폴더내cp949 euc-kr형식 파일을 에서utf-8파일변환 쉽게 하는법 본문
'''
파일명 : euc2utf8.php
기능 : euc-kr -> utf-8 파일변환.
'''
import os
import codecs
def convert_file_to_utf8(filename):
try:
# 파일을 CP949 인코딩으로 열어 내용을 읽음
with codecs.open(filename, 'r', 'cp949') as file:
content = file.read()
# 파일을 UTF-8 인코딩으로 다시 쓰기
with codecs.open(filename, 'w', 'utf-8') as file:
file.write(content)
print(f"Converted {filename} to UTF-8")
except Exception as e:
print(f"Error converting {filename}: {e}")
def convert_directory(directory):
# 지정된 디렉토리 내의 모든 파일을 탐색
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(('.css', '.php', '.html', '.htm', '.js')):
filepath = os.path.join(root, file)
try:
convert_file_to_utf8(filepath)
except Exception as e:
print(f"Error processing {filepath}: {e}")
if name == 'main':
#directories = ['./test', '../js', '../css', '../doc']
#for directory in directories:
# convert_directory(directory)
directory = './test'
directory = '../js'
directory = '../css'
directory = '../doc'
directory = '../include'
directory = '../lib'
directory = '../_yy'
convert_directory(directory)
'IT인터넷 > 기타 유용한 것들' 카테고리의 다른 글
VMWare비정상종료시 시작이 안되는 문제 해결 방법 (2) | 2024.02.03 |
---|---|
드디어 티스토리가 응답했다 (5) | 2024.01.17 |
ipTime원격접속시 악성스크립트(CSRF)오류 문제 해결법 (1) | 2024.01.17 |