~ubuntu-branches/ubuntu/utopic/freeipa/utopic-proposed

« back to all changes in this revision

Viewing changes to ipapython/py_default_encoding/default_encoding_utf8.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2013-09-03 17:13:27 UTC
  • Revision ID: package-import@ubuntu.com-20130903171327-s3f56x6vxz0o1jq5
Tags: upstream-3.3.4
ImportĀ upstreamĀ versionĀ 3.3.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Authors:
 
3
 *   John Dennis <jdennis@redhat.com>
 
4
 *
 
5
 * Copyright (C) 2009  Red Hat
 
6
 * see file 'COPYING' for use and warranty information
 
7
 *
 
8
 * This program is free software you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation, either version 3 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#include <Python.h>
 
23
 
 
24
PyDoc_STRVAR(setdefaultencoding_doc,
 
25
"setdefaultencoding(encoding='utf-8')\n\
 
26
\n\
 
27
Set the current default string encoding used by the Unicode implementation.\n\
 
28
Defaults to utf-8."
 
29
);
 
30
 
 
31
static PyObject *
 
32
setdefaultencoding(PyObject *self, PyObject *args, PyObject *kwds)
 
33
{
 
34
    static char *kwlist[] = {"utf-8", NULL};
 
35
    char *encoding;
 
36
 
 
37
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:setdefaultencoding", kwlist, &encoding))
 
38
        return NULL;
 
39
 
 
40
    if (PyUnicode_SetDefaultEncoding(encoding))
 
41
        return NULL;
 
42
 
 
43
    Py_RETURN_NONE;
 
44
}
 
45
 
 
46
static PyMethodDef methods[] = {
 
47
    {"setdefaultencoding", (PyCFunction)setdefaultencoding, METH_VARARGS|METH_KEYWORDS, setdefaultencoding_doc},
 
48
        {NULL,          NULL}           /* sentinel */
 
49
};
 
50
 
 
51
 
 
52
PyMODINIT_FUNC
 
53
initdefault_encoding_utf8(void) 
 
54
{
 
55
    PyUnicode_SetDefaultEncoding("utf-8");
 
56
    Py_InitModule3("default_encoding_utf8", methods, "Forces the default encoding to utf-8");
 
57
}