/* * Minimal bootstrap RTL (runtime library) - String functions. * * Copyright © 2025 Samuel Lidén Borell * * SPDX-License-Identifier: EUPL-1.2+ OR LGPL-2.1-or-later */ #include #include "rtl.h" #include "internal.h" const unsigned char *SLUL__decode_string( const struct String *str, SlulInt *len_out) { const unsigned char *s = (const unsigned char *)str; unsigned char format = (unsigned char)*s; SlulInt len; if (format < SLUL_SL_UPTO_17F) { len = format; s++; } else if (format < SLUL_SL_UPTO_1017F) { len = 0x80 + s[1]; s += 2; } else if (format < SLUL_SL_UPTO_10001017F) { len = 0x180U + (s[1] | s[2]<<8); s += 3; } else { len = 0x10180U + (s[1] | s[2]<<8 | s[3]<<16); s += 4; } if (len_out) *len_out = len; return s; }