forked from hollowaykeanho/Upscaler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init: ported Replace_{String,Unicode} primitive function
Since there are a number of level 1 libraries using the string function, we have to port its primitive ones into HestiaKERNEL library. Let's do this. This patch ports Replace_{String,Unicode} primitive function into HestiaKERNEL library into init/ directory. Co-authored-by: Shuralyov, Jean <[email protected]> Co-authored-by: Galyna, Cory <[email protected]> Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]> Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
- Loading branch information
1 parent
0e986e6
commit fb50e28
Showing
7 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\String\To_String_From_Unicode.ps1" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Replace_Unicode.ps1" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\To_Unicode_From_String.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Replace-String { | ||
param ( | ||
[string]$___input, | ||
[string]$___from, | ||
[string]$___to, | ||
[int32]$___count, | ||
[int32]$___ignore, | ||
[string]$___from_right | ||
) | ||
|
||
|
||
# execute | ||
$___content = HestiaKERNEL-To-Unicode-From-String $___input | ||
$___chars_from = HestiaKERNEL-To-Unicode-From-String $___from | ||
$___chars_to = HestiaKERNEL-To-Unicode-From-String $___to | ||
$___content = HestiaKERNEL-Replace-Unicode $___content ` | ||
$___chars_from ` | ||
$___chars_to ` | ||
$___count ` | ||
$___ignore | ||
|
||
|
||
# report status | ||
return HestiaKERNEL-To-String-From-Unicode $___content | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${LIBS_HESTIA}/HestiaKERNEL/String/To_String_From_Unicode.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Replace_Unicode.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/To_Unicode_From_String.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Replace_String() { | ||
#___input="$1" | ||
#___from="$2" | ||
#___to="$3" | ||
#___count="$4" | ||
#___ignore="$5" | ||
#___direction="$6" | ||
|
||
|
||
# execute | ||
___content="$(HestiaKERNEL_To_Unicode_From_String "$1")" | ||
___chars_from="$(HestiaKERNEL_To_Unicode_From_String "$2")" | ||
___chars_to="$(HestiaKERNEL_To_Unicode_From_String "$3")" | ||
___content="$(HestiaKERNEL_Replace_Unicode "$___content" \ | ||
"$___chars_from" \ | ||
"$___chars_to" \ | ||
"$4" \ | ||
"$5" \ | ||
"$6" | ||
)" | ||
|
||
|
||
# report status | ||
printf -- "%b" "$(HestiaKERNEL_To_String_From_Unicode "$___content")" | ||
return $? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Replace_Left_Unicode.ps1" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Replace_Right_Unicode.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Replace-Unicode { | ||
param ( | ||
[uint32[]]$___content_unicode, | ||
[uint32[]]$___from_unicode, | ||
[uint32[]]$___to_unicode, | ||
[int32]$___count, | ||
[int32]$___ignore, | ||
[string]$___from_right | ||
) | ||
|
||
|
||
# execute | ||
if ($___from_right -ne "") { | ||
return HestiaKERNEL-Replace-Right-Unicode ` | ||
$___content_unicode ` | ||
$___from_unicode ` | ||
$___to_unicode ` | ||
$___count ` | ||
$___ignore | ||
} else { | ||
return HestiaKERNEL-Replace-Left-Unicode ` | ||
$___content_unicode ` | ||
$___from_unicode ` | ||
$___to_unicode ` | ||
$___count ` | ||
$___ignore | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]> | ||
# | ||
# | ||
# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). | ||
# You must comply with the license to use the content. Get the License at: | ||
# | ||
# https://doi.org/10.5281/zenodo.13770769 | ||
# | ||
# You MUST ensure any interaction with the content STRICTLY COMPLIES with | ||
# the permissions and limitations set forth in the license. | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Replace_Left_Unicode.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Replace_Right_Unicode.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Replace_Unicode() { | ||
#___content_unicode="$1" | ||
#___from_unicode="$2" | ||
#___to_unicode="$3" | ||
#___count="$4" | ||
#___ignore="$5" | ||
#___from_right="$6" | ||
|
||
|
||
# execute | ||
if [ ! "$6" = "" ]; then | ||
printf -- "%b" "$(HestiaKERNEL_Replace_Right_Unicode "$1" "$2" "$3" "$4" "$5")" | ||
else | ||
printf -- "%b" "$(HestiaKERNEL_Replace_Left_Unicode "$1" "$2" "$3" "$4" "$5")" | ||
fi | ||
|
||
|
||
# report status | ||
return $? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters