Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
acaa5a16
Kaydet (Commit)
acaa5a16
authored
May 05, 2007
tarafından
Walter Dörwald
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add PyUnicode_FromString(), which create a unicode object from a
const char * (i.e. 0-terminated latin-1 encoded bytes).
üst
1255ed62
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
concrete.tex
Doc/api/concrete.tex
+11
-0
unicodeobject.h
Include/unicodeobject.h
+8
-0
unicodeobject.c
Objects/unicodeobject.c
+45
-0
No files found.
Doc/api/concrete.tex
Dosyayı görüntüle @
acaa5a16
...
...
@@ -995,6 +995,17 @@ use these APIs:
\var
{
u
}
is
\NULL
{}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyUnicode
_
FromString
}{
const char *u
}
Create a Unicode Object from the char buffer
\var
{
u
}
of the.
\var
{
u
}
must be 0-terminated, the bytes will be interpreted as
being latin-1 encoded.
\var
{
u
}
may also be
\NULL
{}
which causes the
contents to be undefined. It is the user's responsibility to fill
in the needed data. The buffer is copied into the new object.
If the buffer is not
\NULL
{}
, the return value might be a shared object.
Therefore, modification of the resulting Unicode object is only allowed
when
\var
{
u
}
is
\NULL
{}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
Py
_
UNICODE*
}{
PyUnicode
_
AsUnicode
}{
PyObject *unicode
}
Return a read-only pointer to the Unicode object's internal
\ctype
{
Py
_
UNICODE
}
buffer,
\NULL
{}
if
\var
{
unicode
}
is not a Unicode
...
...
Include/unicodeobject.h
Dosyayı görüntüle @
acaa5a16
...
...
@@ -172,6 +172,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
# define PyUnicode_FromObject PyUnicodeUCS2_FromObject
# define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal
# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode
# define PyUnicode_FromString PyUnicodeUCS2_FromString
# define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS2_GetMax
...
...
@@ -250,6 +251,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
# define PyUnicode_FromObject PyUnicodeUCS4_FromObject
# define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal
# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode
# define PyUnicode_FromString PyUnicodeUCS4_FromString
# define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS4_GetMax
...
...
@@ -427,6 +429,12 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
Py_ssize_t
size
/* size of buffer */
);
/* Similar to PyUnicode_FromUnicode(), but u points to null-terminated
Latin-1 encoded bytes */
PyAPI_FUNC
(
PyObject
*
)
PyUnicode_FromString
(
const
char
*
u
/* string */
);
/* Return a read-only pointer to the Unicode object's internal
Py_UNICODE buffer. */
...
...
Objects/unicodeobject.c
Dosyayı görüntüle @
acaa5a16
...
...
@@ -393,6 +393,51 @@ PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u,
return
(
PyObject
*
)
unicode
;
}
PyObject
*
PyUnicode_FromString
(
const
char
*
u
)
{
PyUnicodeObject
*
unicode
;
Py_ssize_t
size
=
strlen
(
u
);
/* If the Unicode data is known at construction time, we can apply
some optimizations which share commonly used objects. */
if
(
u
!=
NULL
)
{
/* Optimization for empty strings */
if
(
size
==
0
&&
unicode_empty
!=
NULL
)
{
Py_INCREF
(
unicode_empty
);
return
(
PyObject
*
)
unicode_empty
;
}
/* Single character Unicode objects in the Latin-1 range are
shared when using this constructor */
if
(
size
==
1
&&
*
u
<
256
)
{
unicode
=
unicode_latin1
[
*
u
];
if
(
!
unicode
)
{
unicode
=
_PyUnicode_New
(
1
);
if
(
!
unicode
)
return
NULL
;
unicode
->
str
[
0
]
=
*
u
;
unicode_latin1
[
*
u
]
=
unicode
;
}
Py_INCREF
(
unicode
);
return
(
PyObject
*
)
unicode
;
}
}
unicode
=
_PyUnicode_New
(
size
);
if
(
!
unicode
)
return
NULL
;
/* Copy the Unicode data into the new object */
if
(
u
!=
NULL
)
{
char
*
p
=
unicode
->
str
;
while
(
*
p
++
=
*
u
++
)
;
}
return
(
PyObject
*
)
unicode
;
}
#ifdef HAVE_WCHAR_H
PyObject
*
PyUnicode_FromWideChar
(
register
const
wchar_t
*
w
,
...
...
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