Skip to content

Commit

Permalink
Use cp1252 encoding for latin1 charset (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Nov 21, 2019
1 parent c3e5a63 commit a4f9847
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions pymysql/charset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def encoding(self):
name = self.name
if name in ('utf8mb4', 'utf8mb3'):
return 'utf8'
if name == 'latin1':
return 'cp1252'
if name == 'koi8r':
return 'koi8_r'
if name == 'koi8u':
return 'koi8_u'
return name

@property
Expand Down Expand Up @@ -202,11 +208,3 @@ def by_name(self, name):

charset_by_name = _charsets.by_name
charset_by_id = _charsets.by_id


#TODO: remove this
def charset_to_encoding(name):
"""Convert MySQL's charset name to Python's codec name"""
if name in ('utf8mb4', 'utf8mb3'):
return 'utf8'
return name
2 changes: 1 addition & 1 deletion pymysql/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time

from .constants import FIELD_TYPE, FLAG
from .charset import charset_by_id, charset_to_encoding
from .charset import charset_by_id


def escape_item(val, charset, mapping=None):
Expand Down

1 comment on commit a4f9847

@francisar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use cp1252 encoding for latin1 charset, I have problems on mysql version 5.6.28

Please sign in to comment.