<<
path:
root/public/0x2lib.git/html/0x2_String.jai
blob: fc4663ddfca67cd059acc5b221b896c8e017f931
[raw]
[clear marker]
6to_string :: builder_to_string;
15string_pad_left :: (s: string, padding: int, char: string = " ") -> string {
26string_pad_right :: (s: string, padding: int, char: string = " ") -> string {
37string_pad_lr :: (s: string, padding: int, char: string = " ") -> string {
39 half: int = xx floor(xx length / 2.0);
56__string_pad :: ($code: string) #expand {
58 length := `padding - `s.count;
62 `return builder_to_string(*sb);
66using,only(String_Builder, builder_to_string, append) Basic :: #import "Basic";
67using,only(floor) Math :: #import "Math";
71------------------------------------------------------------------------------
72This software is available under 2 licenses -- choose whichever you prefer.
73------------------------------------------------------------------------------
74ALTERNATIVE A - MIT License
75Copyright (c) 2026 Adam Blazeowsky
76Permission is hereby granted, free of charge, to any person obtaining a copy of
77this software and associated documentation files (the "Software"), to deal in
78the Software without restriction, including without limitation the rights to
79use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
80of the Software, and to permit persons to whom the Software is furnished to do
81so, subject to the following conditions:
82The above copyright notice and this permission notice shall be included in all
83copies or substantial portions of the Software.
84THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
91------------------------------------------------------------------------------
92ALTERNATIVE B - Public Domain (www.unlicense.org)
93This is free and unencumbered software released into the public domain.
94Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
95software, either in source code form or as a compiled binary, for any purpose,
96commercial or non-commercial, and by any means.
97In jurisdictions that recognize copyright laws, the author or authors of this
98software dedicate any and all copyright interest in the software to the public
99domain. We make this dedication for the benefit of the public at large and to
100the detriment of our heirs and successors. We intend this dedication to be an
101overt act of relinquishment in perpetuity of all present and future rights to
102this software under copyright law.
103THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
107ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
108WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
109------------------------------------------------------------------------------