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 Is_Punctuation_{String,Unicode} primitive functions
Since a number of level 1 Hestia libraries use string functions, we have to port its primitive ones into HestiaKERNEL library package. Hence, let's do this. This patch ports Is_Punctuation_{String,Unicode} primitive function into HestiaKERNEL library in 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
55ef361
commit 5df0336
Showing
12 changed files
with
220 additions
and
10 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
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,32 @@ | ||
# 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\Error_Codes.ps1" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Punctuation_Unicode.ps1" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\To_Unicode_From_String.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaKERNEL-Is-Punctuation-String { | ||
param ( | ||
[string]$___rune | ||
) | ||
|
||
|
||
# validate input | ||
if ($(HestiaKERNEL-To-Unicode-From-String $___rune) -ne ${env:HestiaKERNEL_ERROR_OK}) { | ||
return ${env:HestiaKERNEL_ERROR_DATA_INVALID} | ||
} | ||
|
||
|
||
# execute | ||
return HestiaKERNEL-Is-Punctuation-Unicode [uint32]$___rune[0] | ||
} |
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,33 @@ | ||
#!/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/Error_Codes.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Is_Punctuation_Unicode.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/To_Unicode_From_String.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Is_Punctuation_String() { | ||
#___rune="$1" | ||
|
||
|
||
# execute | ||
___unicode="$(HestiaKERNEL_To_Unicode_From_String "$1")" | ||
if [ $? -ne $HestiaKERNEL_ERROR_OK ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_INVALID | ||
return $HestiaKERNEL_ERROR_DATA_INVALID | ||
fi | ||
|
||
|
||
printf -- "%d" "$(HestiaKERNEL_Is_Punctuation_Unicode "${___unicode%%, *}")" | ||
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,54 @@ | ||
# 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\Error_Codes.ps1" | ||
. "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Number.ps1" | ||
|
||
|
||
|
||
|
||
function HestiaSTRING-Is-Punctuation-Unicode { | ||
param ( | ||
[uint32]$___unicode | ||
) | ||
|
||
|
||
# validate input | ||
if ($(HestiaKERNEL-Is-Number $___unicode) -ne ${env:HestiaKERNEL_ERROR_OK}) { | ||
return ${env:HestiaKERNEL_ERROR_DATA_INVALID} | ||
} | ||
|
||
|
||
# execute | ||
if ( | ||
(($___unicode -ge 0x0021) -and ($___unicode -le 0x002F)) -or | ||
(($___unicode -ge 0x003A) -and ($___unicode -le 0x0040)) -or | ||
(($___unicode -ge 0x007B) -and ($___unicode -le 0x007E)) -or | ||
(($___unicode -ge 0x00A1) -and ($___unicode -le 0x00BF)) -or | ||
(($___unicode -ge 0x2000) -and ($___unicode -le 0x206F)) -or | ||
(($___unicode -ge 0x2E00) -and ($___unicode -le 0x2E7F)) -or | ||
(($___unicode -ge 0x3000) -and ($___unicode -le 0x303F)) -or | ||
(($___unicode -ge 0x12400) -and ($___unicode -le 0x1247F)) -or | ||
(($___unicode -ge 0x16FE0) -and ($___unicode -le 0x16FFF)) | ||
) { | ||
# Latin-1 Script (0x0021-0x002F; 0x003A-0x0040) | ||
# Latin-1 Suppliment Script (0x00A0-0x00BF) | ||
# General Punctuation Script (0x2000-0x206F) | ||
# Supplemental Punctuation Script (0x2E00-0x2E7F) | ||
# CJK Symbols and Punctuation Script (0x3000-0x303F) | ||
# Cuneiform Number and Punctuation Script (0x12400-0x1247F) | ||
# Ideographic Symbols and Punctuation Script (0x16FE0-0x16FFF) | ||
return ${env:HestiaKERNEL_ERROR_OK} | ||
} | ||
|
||
|
||
# report status | ||
return ${env:HestiaKERNEL_ERROR_DATA_INVALID} | ||
} |
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,54 @@ | ||
#!/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/Error_Codes.sh" | ||
. "${LIBS_HESTIA}/HestiaKERNEL/Is_Number.sh" | ||
|
||
|
||
|
||
|
||
HestiaKERNEL_Is_Punctuation_Unicode() { | ||
#___unicode="$1" | ||
|
||
|
||
# validate input | ||
if [ "$(HestiaKERNEL_Is_Number "$1")" -ne $HestiaKERNEL_ERROR_OK ]; then | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_INVALID | ||
return $HestiaKERNEL_ERROR_DATA_INVALID | ||
fi | ||
|
||
|
||
# execute | ||
if ([ $1 -ge 33 ] && [ $1 -le 47 ]) || | ||
([ $1 -ge 58 ] && [ $1 -le 64 ]) || | ||
([ $1 -ge 123 ] && [ $1 -le 126 ]) || | ||
([ $1 -ge 161 ] && [ $1 -le 191 ]) || | ||
([ $1 -ge 8192 ] && [ $1 -le 8303 ]) || | ||
([ $1 -ge 11776 ] && [ $1 -le 11903 ]) || | ||
([ $1 -ge 12288 ] && [ $1 -le 12351 ]) || | ||
([ $1 -ge 74752 ] && [ $1 -le 74879 ]) || | ||
([ $1 -ge 94176 ] && [ $1 -le 94207 ]); then | ||
# Latin-1 Script (0x0021-0x002F; 0x003A-0x0040) | ||
# Latin-1 Suppliment Script (0x00A0-0x00BF) | ||
# General Punctuation Script (0x2000-0x206F) | ||
# Supplemental Punctuation Script (0x2E00-0x2E7F) | ||
# CJK Symbols and Punctuation Script (0x3000-0x303F) | ||
# Cuneiform Number and Punctuation Script (0x12400-0x1247F) | ||
# Ideographic Symbols and Punctuation Script (0x16FE0-0x16FFF) | ||
printf -- "%d" $HestiaKERNEL_ERROR_OK | ||
return $HestiaKERNEL_ERROR_OK | ||
fi | ||
|
||
|
||
# report status | ||
printf -- "%d" $HestiaKERNEL_ERROR_DATA_INVALID | ||
return $HestiaKERNEL_ERROR_DATA_INVALID | ||
} |
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
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
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