반응형

https://pypi.org/project/chardet/

 

Project description

Chardet: The Universal Character Encoding Detector

 
 
 
Detects
  • ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants)
  • Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (Traditional and Simplified Chinese)
  • EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP (Japanese)
  • EUC-KR, ISO-2022-KR, Johab (Korean)
  • KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251 (Cyrillic)
  • ISO-8859-5, windows-1251 (Bulgarian)
  • ISO-8859-1, windows-1252, MacRoman (Western European languages)
  • ISO-8859-7, windows-1253 (Greek)
  • ISO-8859-8, windows-1255 (Visual and Logical Hebrew)
  • TIS-620 (Thai)

Note

Our ISO-8859-2 and windows-1250 (Hungarian) probers have been temporarily disabled until we can retrain the models.

Requires Python 3.7+.

반응형
반응형

[VS Code] 인코딩 변경

VS Code 사용하다보면 웹페이지 특성상  UTF-8 또는 EUC-KR 이 있는데, 

자동으로 되어 있어도 페이지와 맞지 않는 인코딩이 선택될때가 있다. 

 

F1 키를 입력하거나, 오른쪽 하단의 인코딩 정보를 클릭하면 아래 이미지처럼 Reopne with Encoding 이 나온다. 

그러면 그 중에 맞는 인코딩을 선택하면 된다. 

반응형
반응형

[PYTHON] 파일 인코딩 관련

 

UTF-8

UTF-8-SIG

""" 
    인코딩 정보
"""
import os
import sys 
 
 
#작업하는 경로(위치)가 어디인지 확인
#print(os.getcwd())
prePath_in = "./Project/" 
prePath_out = "./Project/" 



#1. 기본 내용적기

# 기본 텍스트 신규 입력
file = open("test.txt", "w")
file.write("내용입력")
file.close()

# 한글깨짐 방지 ENCODING UTF-8
file = open("test.txt", "w", encoding="UTF-8")
file.write("내용입력")
file.close()

# 한글깨짐 방지2 ENCODING UTF-8
# txt는 UTF-8로도 충분한데 csv는 UTF-8로만 하면 읽을땐 다른걸로 읽을 경우 깨짐 현상 발생
file = open("test.csv", "w", encoding="UTF-8-sig")
file.write("test,test,test\n")
file.write("잘되나,안된다,오된다\n")
file.close()

# 참고
# Permission denied: 'test.csv' 가 나온다
# 파일 열고 있어서 수정할 수 없다는거다. 꺼주자.

# 추가 입력
file = open("test.txt", "a")
file.write("추가 내용입력")
file.close()


# 읽기
file = open("test.txt", "r", encoding="UTF-8")
print(file.read())
file.close()

# with 함수 : open & close 포함 
with open("test.txt", "w", encoding="UTF-8") as file:
    file.write("내용입력")
with open("test.txt", "r", encoding="UTF-8") as file:
    print(file.read())
 

 

#2. print 한거 txt 파일에 넣기

# sys.stdout 함수 사용하여 log 저장하기
f = open('test.txt','w', encoding='utf-8') # 로그 저장할 file open
sys.stdout = f
print("내용입력")
sys.stdout = sys.__stdout__   # 원래의 stdout으로 복구
f.close()                     # 로그 파일 닫기

#이렇게 해도 되긴 하는데.. 프로그램이 종료 안되면 문제가 생길듯?
sys.stdout = open('test.txt','w', encoding='utf-8')
print("내용입력")
반응형
반응형

[JEUS 8] response charset 변경하기 페이지 인코딩 변경

webApplication/WEB-INF/jeus-web-dd.xml 을 만듭니다.

 
<?xml version="1.0" encoding="UTF-8"?> 
<jeus-web-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus"> 
<context-path>/euckr</context-path> 
<encoding> 
<response-encoding> 
<default>EUC-KR</default> 
</response-encoding> 
</encoding> 
</jeus-web-dd>
 

 

자 이렇게 되면
받는 쪽 body 로 제우스는 EUC-KR의 인코딩 형태로 html 을 던져 줍니다.

출처:https://ipex.tistory.com/entry/JEUS-8-response-charset-변경하기-페이지-인코딩-변경[깍돌이]

----------------------------------------------------------------------------------------------------------------------------
 http://blog.naver.com/hwanwhat81/221181267297 
ja 로 jeus admin(관리자 모드 접속)하여

applist 하면 container 정보들이 출력..
jeus 홈디렉토리 config 파일에 가보면 서비스 디렉토리 안에 container list 가 존재한다.
한글깨짐 현상이 발생하는 컨테이너로 가보면
WEBmain.xml 이 존재.

vi 로 들어가서 편집해 준다.  

<context-group>
        <group-name>MyGroup</group-name>
        <encoding>
            <request-url-encoding>
                <default>utf-8</default>
                <forced>utf-8</forced>
            </request-url-encoding>
            <request-encoding>
                <default>utf-8</default>
                <forced>utf-8</forced>
            </request-encoding>
            <response-encoding>
                <default>utf-8</default>
                <forced>utf-8</forced>
            </response-encoding>
        </encoding>
생략 ....
</context-group> 



----------------------------------------------------------------------------------------------------------------------------
file.encoding ansi_x3.4-1968

분명히 utf-8로 셋팅 되었는데 Jeus는 가끔 미쳐서 파일 인코딩을 제대로 인지 못하는 경우가 있다.

String fileEncoding=System.getProperty("file.encoding");

이럴 경우 Jeus의 설정 파일에서( JEUSMain.xml ) 컨테이너 설정에 -Dfile.encoding=UTF-8 를 추가 해야 한다.

출처: https://lahuman.jabsiri.co.kr/57 [lahuman & jabsiri 노트]

----------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------

https://waspro.tistory.com/183

 

[JEUS] Encoding 설정에 따른 출력 Test

본 포스팅은 Encoding 관련 우선순위 테스트입니다. Request Encoding, Response Encoding 각각 우선순위에 대한 테스트를 수행할 예정입니다. 먼저 Request Encoding 우선순위 테스트입니다. JEUS의 Encoding JEU..

waspro.tistory.com

 

반응형
반응형

https://www.tensorflow.org/api_docs/python/tf/compat


Module: tf.compat

Module tf.compat

Functions for Python 2 vs. 3 compatibility.

Conversion routines

In addition to the functions below, as_str converts an object to a str.

Types

The compatibility module also provides the following types:

  • bytes_or_text_types
  • complex_types
  • integral_types
  • real_types

Members

as_bytes(...): 바이트 또는 유니 코드를 bytesutf-8 인코딩을 사용하여 텍스트 로 변환합니다 .

as_str(...): 바이트 또는 유니 코드를 bytesutf-8 인코딩을 사용하여 텍스트 로 변환합니다 .

as_str_any(...)str와 같이 변환 str(value)하지만 as_strfor를 사용 합니다 bytes.

as_text(...): 주어진 인수를 유니 코드 문자열로 반환합니다.


Constant bytes_or_text_types

Constant complex_types

Constant integral_types

Constant real_types

Defined in tensorflow/python/util/compat.py.


반응형
반응형

[인코딩] Form 전송시 euc-kr 페이지에서 utf-8로 데이터 전송하기


일반 form에 인코딩을 설정 한다.



그런데, 폼 전송시 인코딩 변경이 안된다면.

IE에서 특히 그런 현상 발생함.


그럴땐, Form 전송 스크립트에 인코딩 변경 스크립트를 삽입한다.

엘리먼트 전체를 utf-8로 변경해서 전송한다. 그리고, 다시 euc-kr 로 변경





 

 

 

 

 

.




반응형
반응형

ASP 인코딩


* 페이지 속성을 정의


 <%@ codepage="65001" language="VBSCRIPT" %>

 

 0 - ANSI(default)
 949 - 한국어(EUC-KR)
 65001 - 유니코드(UTF-8)
 65535 - 유니코드(UTF-16)

 

* 메타태그 설정

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" >

 

* 현재 세션사용자의 동적 텍스트 인코딩 코드 설정

 

    Session.CodePage = 65001
    Session.CodePage = 949

 

* ASP의 response.charset을 이용해서 문자코드 세트명 지정

 

    Response.Charset = "EUC=KR"

 

 

* UTF-8 인데 계속 한글이 깨지면 아래와 같이 다 적용해보자.

 

<%@Language="VBScript" CODEPAGE="65001" %>
<%
    Session.CodePage = 65001

    Response.CharSet = "UTF-8"
   

 

 

<%@  codepage="949" language="VBScript" %><% 
'session.codepage = 65001  ' codepage="949" language 
Session.CodePage = 949 
'Response.expires=-1 
Response.ContentType = "application/json" 
Response.Charset = "euc-kr" 
'Response.Charset = "utf-8" 

 

 

 

* utf-8로 만들기 : 페이지 최상단에 입력

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.AddHeader "Cache-Control", "no-cache"
Response.AddHeader "Expires", "0"
Response.AddHeader "Pragma", "no-cache"
Response.ContentType = "text/html; charset=utf-8"
%

 

 

 

 

 

반응형

+ Recent posts