|
1 | 1 | #------------------------------------------------------------------------------ |
2 | | -# Copyright (c) 2020, 2025, Oracle and/or its affiliates. |
| 2 | +# Copyright (c) 2020, 2026, Oracle and/or its affiliates. |
3 | 3 | # |
4 | 4 | # This software is dual-licensed to you under the Universal Permissive License |
5 | 5 | # (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License |
@@ -198,11 +198,19 @@ cdef class BaseThinLobImpl(BaseLobImpl): |
198 | 198 |
|
199 | 199 | cdef const char* _get_encoding(self): |
200 | 200 | """ |
201 | | - Return the encoding used by the LOB. |
| 201 | + Return the encoding used by the LOB. NCLOB always uses UTF-16. CLOB |
| 202 | + uses UTF-16 if the "variable length character set" flag is set, but |
| 203 | + uses UTF-16LE if the "little endian" flag is set (this flag is only for |
| 204 | + those CLOBs that were originally created in Oracle Database 9i). In all |
| 205 | + other cases, the encoding UTF-8 is used. |
202 | 206 | """ |
203 | | - if self.dbtype._csfrm == CS_FORM_NCHAR \ |
204 | | - or self._locator[TNS_LOB_LOC_OFFSET_FLAG_3] & \ |
| 207 | + if self.dbtype._csfrm == CS_FORM_NCHAR: |
| 208 | + return ENCODING_UTF16 |
| 209 | + elif self._locator[TNS_LOB_LOC_OFFSET_FLAG_3] & \ |
205 | 210 | TNS_LOB_LOC_FLAGS_VAR_LENGTH_CHARSET: |
| 211 | + if self._locator[TNS_LOB_LOC_OFFSET_FLAG_4] & \ |
| 212 | + TNS_LOB_LOC_FLAGS_LITTLE_ENDIAN: |
| 213 | + return ENCODING_UTF16LE |
206 | 214 | return ENCODING_UTF16 |
207 | 215 | return ENCODING_UTF8 |
208 | 216 |
|
|
0 commit comments