Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ca924537
Commit
ca924537
authored
Mar 28, 2000
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MBCS codecs. (Win32 only.) By Mark Hammond.
parent
2fe8d6dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+59
-0
No files found.
Objects/unicodeobject.c
View file @
ca924537
...
@@ -73,6 +73,9 @@ Unicode Integration Proposal (see file Misc/unicode.txt).
...
@@ -73,6 +73,9 @@ Unicode Integration Proposal (see file Misc/unicode.txt).
#define INT_MAX 2147483647
#define INT_MAX 2147483647
#endif
#endif
#ifdef MS_WIN32
#include <windows.h>
#endif
/* Limit for the Unicode object free list */
/* Limit for the Unicode object free list */
#define MAX_UNICODE_FREELIST_SIZE 1024
#define MAX_UNICODE_FREELIST_SIZE 1024
...
@@ -1479,6 +1482,62 @@ PyObject *PyUnicode_AsASCIIString(PyObject *unicode)
...
@@ -1479,6 +1482,62 @@ PyObject *PyUnicode_AsASCIIString(PyObject *unicode)
NULL
);
NULL
);
}
}
#ifdef MS_WIN32
/* --- MBCS codecs for Windows -------------------------------------------- */
PyObject
*
PyUnicode_DecodeMBCS
(
const
char
*
s
,
int
size
,
const
char
*
errors
)
{
PyUnicodeObject
*
v
;
Py_UNICODE
*
p
;
/* First get the size of the result */
DWORD
usize
=
MultiByteToWideChar
(
CP_ACP
,
0
,
s
,
size
,
NULL
,
0
);
if
(
usize
==
0
)
return
PyErr_SetFromWindowsErrWithFilename
(
0
,
NULL
);
v
=
_PyUnicode_New
(
usize
);
if
(
v
==
NULL
)
return
NULL
;
if
(
usize
==
0
)
return
(
PyObject
*
)
v
;
p
=
PyUnicode_AS_UNICODE
(
v
);
if
(
0
==
MultiByteToWideChar
(
CP_ACP
,
0
,
s
,
size
,
p
,
usize
))
{
Py_DECREF
(
v
);
return
PyErr_SetFromWindowsErrWithFilename
(
0
,
NULL
);
}
return
(
PyObject
*
)
v
;
}
PyObject
*
PyUnicode_EncodeMBCS
(
const
Py_UNICODE
*
p
,
int
size
,
const
char
*
errors
)
{
PyObject
*
repr
;
char
*
s
;
/* First get the size of the result */
DWORD
mbcssize
=
WideCharToMultiByte
(
CP_ACP
,
0
,
p
,
size
,
NULL
,
0
,
NULL
,
NULL
);
if
(
mbcssize
==
0
)
return
PyErr_SetFromWindowsErrWithFilename
(
0
,
NULL
);
repr
=
PyString_FromStringAndSize
(
NULL
,
mbcssize
);
if
(
repr
==
NULL
)
return
NULL
;
if
(
mbcssize
==
0
)
return
repr
;
/* Do the conversion */
s
=
PyString_AS_STRING
(
repr
);
if
(
0
==
WideCharToMultiByte
(
CP_ACP
,
0
,
p
,
size
,
s
,
mbcssize
,
NULL
,
NULL
))
{
Py_DECREF
(
repr
);
return
PyErr_SetFromWindowsErrWithFilename
(
0
,
NULL
);
}
return
repr
;
}
#endif
/* MS_WIN32 */
/* --- Character Mapping Codec -------------------------------------------- */
/* --- Character Mapping Codec -------------------------------------------- */
static
static
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment