mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-18 08:41:31 -07:00
Merge remote-tracking branch 'live/master' into macharena
This commit is contained in:
@@ -62,7 +62,7 @@ global_block_descriptor := Block_Descriptor{
|
||||
size = size_of(Internal_Block_Literal),
|
||||
}
|
||||
|
||||
foreign import libSystem "system:System.framework"
|
||||
foreign import libSystem "system:System"
|
||||
foreign libSystem {
|
||||
_NSConcreteGlobalBlock: intrinsics.objc_class
|
||||
_NSConcreteStackBlock: intrinsics.objc_class
|
||||
|
||||
@@ -4,7 +4,7 @@ package darwin
|
||||
import "core:c"
|
||||
|
||||
@(export)
|
||||
foreign import system "system:System.framework"
|
||||
foreign import system "system:System"
|
||||
|
||||
Bool :: b8
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package darwin
|
||||
|
||||
foreign import mach "system:System.framework"
|
||||
foreign import mach "system:System"
|
||||
|
||||
import "core:c"
|
||||
import "base:intrinsics"
|
||||
|
||||
@@ -4,7 +4,7 @@ import "base:intrinsics"
|
||||
|
||||
import "core:sys/posix"
|
||||
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
|
||||
// Incomplete bindings to the proc API on MacOS, add to when needed.
|
||||
|
||||
|
||||
@@ -3,23 +3,13 @@ package darwin
|
||||
// #define OS_WAIT_ON_ADDR_AVAILABILITY \
|
||||
// __API_AVAILABLE(macos(14.4), ios(17.4), tvos(17.4), watchos(10.4))
|
||||
when ODIN_OS == .Darwin {
|
||||
|
||||
when ODIN_PLATFORM_SUBTARGET == .iOS && ODIN_MINIMUM_OS_VERSION >= 17_04_00 {
|
||||
WAIT_ON_ADDRESS_AVAILABLE :: true
|
||||
} else when ODIN_MINIMUM_OS_VERSION >= 14_04_00 {
|
||||
WAIT_ON_ADDRESS_AVAILABLE :: true
|
||||
when ODIN_PLATFORM_SUBTARGET_IOS {
|
||||
WAIT_ON_ADDRESS_AVAILABLE :: ODIN_MINIMUM_OS_VERSION >= 17_04_00
|
||||
ULOCK_WAIT_2_AVAILABLE :: ODIN_MINIMUM_OS_VERSION >= 14_00_00
|
||||
} else {
|
||||
WAIT_ON_ADDRESS_AVAILABLE :: false
|
||||
WAIT_ON_ADDRESS_AVAILABLE :: ODIN_MINIMUM_OS_VERSION >= 14_04_00
|
||||
ULOCK_WAIT_2_AVAILABLE :: ODIN_MINIMUM_OS_VERSION >= 11_00_00
|
||||
}
|
||||
|
||||
when ODIN_PLATFORM_SUBTARGET == .iOS && ODIN_MINIMUM_OS_VERSION >= 14_00_00 {
|
||||
ULOCK_WAIT_2_AVAILABLE :: true
|
||||
} else when ODIN_MINIMUM_OS_VERSION >= 11_00_00 {
|
||||
ULOCK_WAIT_2_AVAILABLE :: true
|
||||
} else {
|
||||
ULOCK_WAIT_2_AVAILABLE :: false
|
||||
}
|
||||
|
||||
} else {
|
||||
WAIT_ON_ADDRESS_AVAILABLE :: false
|
||||
ULOCK_WAIT_2_AVAILABLE :: false
|
||||
|
||||
@@ -28,7 +28,7 @@ init_platform :: proc() {
|
||||
|
||||
macos_version = {int(version.majorVersion), int(version.minorVersion), int(version.patchVersion)}
|
||||
|
||||
when ODIN_PLATFORM_SUBTARGET == .iOS {
|
||||
when ODIN_PLATFORM_SUBTARGET_IOS {
|
||||
os_version.platform = .iOS
|
||||
ws(&b, "iOS")
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package kqueue
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else when ODIN_OS == .Haiku {
|
||||
foreign import lib "system:network"
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD {
|
||||
foreign import lib "system:dl"
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package posix
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import "base:intrinsics"
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD || ODIN_OS == .Linux {
|
||||
foreign import lib "system:pthread"
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import "base:intrinsics"
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import "core:c/libc"
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "system:libucrt.lib"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ when ODIN_OS == .Windows {
|
||||
"system:legacy_stdio_definitions.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import "base:intrinsics"
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import "core:c/libc"
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "system:libucrt.lib"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "system:libucrt.lib"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import "base:intrinsics"
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import libc "system:System.framework"
|
||||
foreign import libc "system:System"
|
||||
} else {
|
||||
foreign import libc "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package posix
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import libc "system:System.framework"
|
||||
foreign import libc "system:System"
|
||||
} else {
|
||||
foreign import libc "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import "core:c"
|
||||
import "core:c/libc"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import "core:c"
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "system:libucrt.lib"
|
||||
} else when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package posix
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package posix
|
||||
import "core:c"
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
foreign import lib "system:System.framework"
|
||||
foreign import lib "system:System"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
}
|
||||
|
||||
@@ -25,11 +25,12 @@ COINIT :: enum DWORD {
|
||||
SPEED_OVER_MEMORY = 0x8,
|
||||
}
|
||||
|
||||
IUnknown_UUID_STRING :: "00000000-0000-0000-C000-000000000046"
|
||||
IUnknown_UUID := &IID{0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}
|
||||
IUnknownVtbl :: IUnknown_VTable
|
||||
IUnknown :: struct {
|
||||
using _iunknown_vtable: ^IUnknown_VTable,
|
||||
}
|
||||
|
||||
IUnknownVtbl :: IUnknown_VTable
|
||||
IUnknown_VTable :: struct {
|
||||
QueryInterface: proc "system" (This: ^IUnknown, riid: REFIID, ppvObject: ^rawptr) -> HRESULT,
|
||||
AddRef: proc "system" (This: ^IUnknown) -> ULONG,
|
||||
|
||||
@@ -170,15 +170,15 @@ wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allo
|
||||
return string(text[:n]), nil
|
||||
}
|
||||
|
||||
wstring_to_utf8_buf :: proc(buf: []u8, s: wstring) -> (res: string) {
|
||||
n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, -1, nil, 0, nil, nil)
|
||||
wstring_to_utf8_buf :: proc(buf: []u8, s: wstring, N := -1) -> (res: string) {
|
||||
n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), nil, 0, nil, nil)
|
||||
if n == 0 {
|
||||
return
|
||||
} else if int(n) > len(buf) {
|
||||
return
|
||||
}
|
||||
|
||||
n2 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, -1, raw_data(buf), n, nil, nil)
|
||||
n2 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, i32(N), raw_data(buf), n, nil, nil)
|
||||
if n2 == 0 {
|
||||
return
|
||||
} else if int(n2) > len(buf) {
|
||||
@@ -196,6 +196,21 @@ wstring_to_utf8_buf :: proc(buf: []u8, s: wstring) -> (res: string) {
|
||||
|
||||
wstring_to_utf8 :: proc{wstring_to_utf8_alloc, wstring_to_utf8_buf}
|
||||
|
||||
/*
|
||||
Converts a UTF-16 string into a regular UTF-8 `string` and allocates the result.
|
||||
If the input is null-terminated, only the part of the input string leading up
|
||||
to it will be converted.
|
||||
|
||||
*Allocates Using Provided Allocator*
|
||||
|
||||
Inputs:
|
||||
- s: The string to be converted
|
||||
- allocator: (default: context.allocator)
|
||||
|
||||
Returns:
|
||||
- res: A cloned and converted string
|
||||
- err: An optional allocator error if one occured, `nil` otherwise
|
||||
*/
|
||||
utf16_to_utf8_alloc :: proc(s: []u16, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) {
|
||||
if len(s) == 0 {
|
||||
return "", nil
|
||||
@@ -203,11 +218,25 @@ utf16_to_utf8_alloc :: proc(s: []u16, allocator := context.temp_allocator) -> (r
|
||||
return wstring_to_utf8(raw_data(s), len(s), allocator)
|
||||
}
|
||||
|
||||
/*
|
||||
Converts a UTF-16 string into a regular UTF-8 `string`, using `buf` as its backing.
|
||||
If the input is null-terminated, only the part of the input string leading up
|
||||
to it will be converted.
|
||||
|
||||
*Uses `buf` for backing*
|
||||
|
||||
Inputs:
|
||||
- s: The string to be converted
|
||||
- buf: Backing buffer for result string
|
||||
|
||||
Returns:
|
||||
- res: A converted string, backed byu `buf`
|
||||
*/
|
||||
utf16_to_utf8_buf :: proc(buf: []u8, s: []u16) -> (res: string) {
|
||||
if len(s) == 0 {
|
||||
return
|
||||
}
|
||||
return wstring_to_utf8(buf, raw_data(s))
|
||||
return wstring_to_utf8(buf, raw_data(s), len(s))
|
||||
}
|
||||
|
||||
utf16_to_utf8 :: proc{utf16_to_utf8_alloc, utf16_to_utf8_buf}
|
||||
|
||||
Reference in New Issue
Block a user