github.com/goplus/llgo@v0.8.3/py/unicode.go (about) 1 /* 2 * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package py 18 19 import ( 20 _ "unsafe" 21 22 "github.com/goplus/llgo/c" 23 ) 24 25 // https://docs.python.org/3/c-api/unicode.html 26 27 // Return a pointer to the UTF-8 encoding of the Unicode object, and store the 28 // size of the encoded representation (in bytes) in size. The size argument can 29 // be nil; in this case no size will be stored. The returned buffer always has 30 // an extra null byte appended (not included in size), regardless of whether 31 // there are any other null code points. 32 // 33 // In the case of an error, nil is returned with an exception set and no size is 34 // stored. 35 // 36 // This caches the UTF-8 representation of the string in the Unicode object, and 37 // subsequent calls will return a pointer to the same buffer. The caller is not 38 // responsible for deallocating the buffer. The buffer is deallocated and pointers 39 // to it become invalid when the Unicode object is garbage collected. 40 // 41 // llgo:link (*Object).CStrAndLen C.PyUnicode_AsUTF8AndSize 42 func (u *Object) CStrAndLen() (*c.Char, uintptr) { return nil, 0 } 43 44 // As CStrAndLen, but does not store the len. 45 // 46 // llgo:link (*Object).CStr C.PyUnicode_AsUTF8 47 func (u *Object) CStr() *c.Char { return nil } 48 49 // Same as CStr. Provided for Go+. 50 // 51 // llgo:link (*Object).Cstr C.PyUnicode_AsUTF8 52 func (u *Object) Cstr() *c.Char { return nil }