diff --git a/CLAUDECODE.md b/CLAUDECODE.md index 4bd9ef6..5f75a5f 100644 --- a/CLAUDECODE.md +++ b/CLAUDECODE.md @@ -428,6 +428,35 @@ Flask 서버는 콘솔에 로그를 출력합니다: --- +## 💡 개발 팁 + +### Windows 한글 깨짐 해결 + +**문제**: Python 스크립트 실행 시 한글이 깨져서 출력됨 (cp949 인코딩 문제) + +**해결 방법**: 스크립트 상단에 UTF-8 인코딩 강제 코드 추가 + +```python +import sys +import os + +# UTF-8 인코딩 강제 (Windows 한글 깨짐 방지) +if sys.platform == 'win32': + import io + sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') + sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8') + +# 나머지 코드... +``` + +**적용된 파일**: +- `backend/import_products_from_mssql.py` +- `backend/view_products.py` + +**효과**: 한글 제품명, 카테고리명이 정상적으로 출력됨 + +--- + ## 📚 참고 자료 ### 주요 라이브러리 @@ -437,13 +466,15 @@ Flask 서버는 콘솔에 로그를 출력합니다: - Pillow: 이미지 처리 - brother_ql: Brother QL 프린터 제어 - PyQt5: POS GUI +- OpenAI: AI 분석 및 제품 태깅 ### 외부 링크 - Flask 문서: https://flask.palletsprojects.com/ - Brother QL Python: https://github.com/pklaus/brother_ql - QRCode 문서: https://pypi.org/project/qrcode/ +- OpenAI API: https://platform.openai.com/docs --- **마지막 업데이트**: 2026-01-23 -**버전**: Phase 3 완료 (간편 적립 + 관리자 페이지 + 거래 세부 조회) +**버전**: Phase 3 완료 (간편 적립 + 관리자 페이지 + 거래 세부 조회 + 제품 태깅 시스템) diff --git a/backend/import_products_from_mssql.py b/backend/import_products_from_mssql.py index f7b016a..b27d4d9 100644 --- a/backend/import_products_from_mssql.py +++ b/backend/import_products_from_mssql.py @@ -4,6 +4,13 @@ MSSQL에서 바코드 제품 데이터를 가져와서 product_master에 채우 import sys import os + +# UTF-8 인코딩 강제 (Windows 한글 깨짐 방지) +if sys.platform == 'win32': + import io + sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') + sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8') + sys.path.insert(0, os.path.dirname(__file__)) from db.dbsetup import DatabaseManager diff --git a/backend/view_products.py b/backend/view_products.py index 2ef6ed3..df4aee2 100644 --- a/backend/view_products.py +++ b/backend/view_products.py @@ -2,10 +2,17 @@ product_master 제품 조회 """ +import sys import sqlite3 import os import json +# UTF-8 인코딩 강제 (Windows 한글 깨짐 방지) +if sys.platform == 'win32': + import io + sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') + sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8') + def view_products(): """product_master 제품 조회""" db_path = os.path.join(os.path.dirname(__file__), 'db', 'mileage.db')