@@ -75,6 +75,7 @@ def to_msgpack(path_or_buf, *args, **kwargs):
75
75
path_or_buf : string File path, buffer-like, or None
76
76
if None, return generated string
77
77
args : an object or objects to serialize
78
+ encoding: encoding for unicode objects
78
79
append : boolean whether to append to an existing msgpack
79
80
(default is False)
80
81
compress : type of compressor (zlib or blosc), default to None (no
@@ -103,7 +104,7 @@ def writer(fh):
103
104
writer (path_or_buf )
104
105
105
106
106
- def read_msgpack (path_or_buf , iterator = False , ** kwargs ):
107
+ def read_msgpack (path_or_buf , encoding = 'utf-8' , iterator = False , ** kwargs ):
107
108
"""
108
109
Load msgpack pandas object from the specified
109
110
file path
@@ -114,6 +115,7 @@ def read_msgpack(path_or_buf, iterator=False, **kwargs):
114
115
Parameters
115
116
----------
116
117
path_or_buf : string File path, BytesIO like or string
118
+ encoding: Encoding for decoding msgpack str type
117
119
iterator : boolean, if True, return an iterator to the unpacker
118
120
(default is False)
119
121
@@ -127,7 +129,7 @@ def read_msgpack(path_or_buf, iterator=False, **kwargs):
127
129
return Iterator (path_or_buf )
128
130
129
131
def read (fh ):
130
- l = list (unpack (fh , ** kwargs ))
132
+ l = list (unpack (fh , encoding = encoding , ** kwargs ))
131
133
if len (l ) == 1 :
132
134
return l [0 ]
133
135
return l
@@ -573,7 +575,7 @@ def create_block(b):
573
575
574
576
575
577
def pack (o , default = encode ,
576
- encoding = 'latin1 ' , unicode_errors = 'strict' , use_single_float = False ,
578
+ encoding = 'utf-8 ' , unicode_errors = 'strict' , use_single_float = False ,
577
579
autoreset = 1 , use_bin_type = 1 ):
578
580
"""
579
581
Pack an object and return the packed bytes.
@@ -587,7 +589,7 @@ def pack(o, default=encode,
587
589
588
590
589
591
def unpack (packed , object_hook = decode ,
590
- list_hook = None , use_list = False , encoding = 'latin1 ' ,
592
+ list_hook = None , use_list = False , encoding = 'utf-8 ' ,
591
593
unicode_errors = 'strict' , object_pairs_hook = None ,
592
594
max_buffer_size = 0 , ext_hook = ExtType ):
593
595
"""
@@ -607,7 +609,7 @@ def unpack(packed, object_hook=decode,
607
609
class Packer (_Packer ):
608
610
609
611
def __init__ (self , default = encode ,
610
- encoding = 'latin1 ' ,
612
+ encoding = 'utf-8 ' ,
611
613
unicode_errors = 'strict' ,
612
614
use_single_float = False ,
613
615
autoreset = 1 ,
@@ -624,7 +626,7 @@ class Unpacker(_Unpacker):
624
626
625
627
def __init__ (self , file_like = None , read_size = 0 , use_list = False ,
626
628
object_hook = decode ,
627
- object_pairs_hook = None , list_hook = None , encoding = 'latin1 ' ,
629
+ object_pairs_hook = None , list_hook = None , encoding = 'utf-8 ' ,
628
630
unicode_errors = 'strict' , max_buffer_size = 0 , ext_hook = ExtType ):
629
631
super (Unpacker , self ).__init__ (file_like = file_like ,
630
632
read_size = read_size ,
0 commit comments