equal
deleted
inserted
replaced
136 >>> assert safelocalstr(b'\\xc3') in {b'\\xc3': 0} |
136 >>> assert safelocalstr(b'\\xc3') in {b'\\xc3': 0} |
137 """ |
137 """ |
138 |
138 |
139 |
139 |
140 def tolocal(s): |
140 def tolocal(s): |
141 # type: (Text) -> bytes |
141 # type: (bytes) -> bytes |
142 """ |
142 """ |
143 Convert a string from internal UTF-8 to local encoding |
143 Convert a string from internal UTF-8 to local encoding |
144 |
144 |
145 All internal strings should be UTF-8 but some repos before the |
145 All internal strings should be UTF-8 but some repos before the |
146 implementation of locale support may contain latin1 or possibly |
146 implementation of locale support may contain latin1 or possibly |
646 r += c |
646 r += c |
647 return r |
647 return r |
648 |
648 |
649 |
649 |
650 def fromutf8b(s): |
650 def fromutf8b(s): |
651 # type: (Text) -> bytes |
651 # type: (bytes) -> bytes |
652 '''Given a UTF-8b string, return a local, possibly-binary string. |
652 '''Given a UTF-8b string, return a local, possibly-binary string. |
653 |
653 |
654 return the original binary string. This |
654 return the original binary string. This |
655 is a round-trip process for strings like filenames, but metadata |
655 is a round-trip process for strings like filenames, but metadata |
656 that's was passed through tolocal will remain in UTF-8. |
656 that's was passed through tolocal will remain in UTF-8. |