diff --git a/init/services/HestiaKERNEL/Is_Punctuation_String.ps1 b/init/services/HestiaKERNEL/Is_Punctuation_String.ps1 new file mode 100644 index 0000000..0d34f71 --- /dev/null +++ b/init/services/HestiaKERNEL/Is_Punctuation_String.ps1 @@ -0,0 +1,32 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# 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 $___rune +} diff --git a/init/services/HestiaKERNEL/Is_Punctuation_String.sh b/init/services/HestiaKERNEL/Is_Punctuation_String.sh new file mode 100644 index 0000000..45018dd --- /dev/null +++ b/init/services/HestiaKERNEL/Is_Punctuation_String.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# 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 $? +} diff --git a/init/services/HestiaKERNEL/Is_Punctuation_Unicode.ps1 b/init/services/HestiaKERNEL/Is_Punctuation_Unicode.ps1 new file mode 100644 index 0000000..f2d142e --- /dev/null +++ b/init/services/HestiaKERNEL/Is_Punctuation_Unicode.ps1 @@ -0,0 +1,54 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# 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} +} diff --git a/init/services/HestiaKERNEL/Is_Punctuation_Unicode.sh b/init/services/HestiaKERNEL/Is_Punctuation_Unicode.sh new file mode 100644 index 0000000..7a9e81a --- /dev/null +++ b/init/services/HestiaKERNEL/Is_Punctuation_Unicode.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# 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 +} diff --git a/init/services/HestiaKERNEL/Is_Whitespace_Unicode.ps1 b/init/services/HestiaKERNEL/Is_Whitespace_Unicode.ps1 index 4bc6309..8e696e7 100644 --- a/init/services/HestiaKERNEL/Is_Whitespace_Unicode.ps1 +++ b/init/services/HestiaKERNEL/Is_Whitespace_Unicode.ps1 @@ -9,7 +9,7 @@ # 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_Unicode.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Number.ps1" @@ -21,8 +21,8 @@ function HestiaKERNEL-Is-Whitespace-Unicode { # validate input - if ($(HestiaKERNEL-Is-Unicode $___unicode) -ne ${env:HestiaKERNEL_ERROR_OK}) { - return ${env:HestiaKERNEL_ERROR_DATA_EMPTY} + if ($(HestiaKERNEL-Is-Number $___unicode) -ne ${env:HestiaKERNEL_ERROR_OK}) { + return ${env:HestiaKERNEL_ERROR_DATA_INVALID} } diff --git a/init/services/HestiaKERNEL/Is_Whitespace_Unicode.sh b/init/services/HestiaKERNEL/Is_Whitespace_Unicode.sh index 3a35b9a..a40315b 100644 --- a/init/services/HestiaKERNEL/Is_Whitespace_Unicode.sh +++ b/init/services/HestiaKERNEL/Is_Whitespace_Unicode.sh @@ -10,7 +10,7 @@ # 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_Unicode.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/Is_Number.sh" @@ -20,8 +20,8 @@ HestiaKERNEL_Is_Whitespace_Unicode() { # validate input - if [ "$(HestiaKERNEL_Is_Unicode "$1")" -ne $HestiaKERNEL_ERROR_OK ]; then - printf -- "" + if [ "$(HestiaKERNEL_Is_Number "$1")" -ne $HestiaKERNEL_ERROR_OK ]; then + printf -- "%d" $HestiaKERNEL_ERROR_DATA_INVALID return $HestiaKERNEL_ERROR_DATA_INVALID fi diff --git a/init/services/HestiaKERNEL/Vanilla.sh.ps1 b/init/services/HestiaKERNEL/Vanilla.sh.ps1 index e253b0d..daafae3 100644 --- a/init/services/HestiaKERNEL/Vanilla.sh.ps1 +++ b/init/services/HestiaKERNEL/Vanilla.sh.ps1 @@ -36,6 +36,8 @@ echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null . "${env:LIBS_HESTIA}\HestiaKERNEL\Error_Codes.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Get_String_Encoder.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Array_Number.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Punctuation_String.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Punctuation_Unicode.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Unicode.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Is_UTF.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Whitespace_String.ps1" @@ -75,6 +77,8 @@ RUN_AS_POWERSHELL . "${LIBS_HESTIA}/HestiaKERNEL/Error_Codes.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Get_String_Encoder.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Is_Array_Number.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/Is_Punctuation_String.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/Is_Punctuation_Unicode.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Is_Unicode.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Is_UTF.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Is_Whitespace_String.sh" diff --git a/init/start.ps1 b/init/start.ps1 index d875489..8337256 100644 --- a/init/start.ps1 +++ b/init/start.ps1 @@ -112,6 +112,18 @@ ${env:LIBS_HESTIA} = "${env:LIBS_UPSCALER}\services" . "${env:LIBS_UPSCALER}\services\i18n\report-success.ps1" ### TEST ZONE +. "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Whitespace_String.ps1" +Write-Host "$(HestiaKERNEL-Is-Whitespace-String " ")" +Write-Host "$(HestiaKERNEL-Is-Whitespace-String "m")" +Write-Host "$(HestiaKERNEL-Is-Whitespace-String "m ")" +Write-Host "$(HestiaKERNEL-Is-Whitespace-String " m")" + +. "${env:LIBS_HESTIA}\HestiaKERNEL\Is_Punctuation_String.ps1" +Write-Host "$(HestiaKERNEL-Is-Punctuation-String ",")" +Write-Host "$(HestiaKERNEL-Is-Punctuation-String "m")" +Write-Host "$(HestiaKERNEL-Is-Punctuation-String "m,")" +Write-Host "$(HestiaKERNEL-Is-Punctuation-String ",m")" + . "${env:LIBS_HESTIA}\HestiaKERNEL\Trim_Right_String.ps1" Write-Host "$(HestiaKERNEL-Trim-Right-String "e你feeeff你你aerg aegE你F" "E你F")" . "${env:LIBS_HESTIA}\HestiaKERNEL\Trim_Left_String.ps1" diff --git a/init/start.sh b/init/start.sh index c71812f..71fd065 100644 --- a/init/start.sh +++ b/init/start.sh @@ -102,6 +102,19 @@ LIBS_HESTIA="${LIBS_UPSCALER}/services" . "${LIBS_UPSCALER}/services/i18n/report-success.sh" ### TEST ZONE +. "${LIBS_HESTIA}/HestiaKERNEL/Is_Whitespace_String.sh" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Whitespace_String " ")" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Whitespace_String "m")" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Whitespace_String "m ")" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Whitespace_String " m")" + + +. "${LIBS_HESTIA}/HestiaKERNEL/Is_Punctuation_String.sh" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Punctuation_String ",")" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Punctuation_String "m")" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Punctuation_String "m,")" +1>&2 printf -- "%d\n" "$(HestiaKERNEL_Is_Punctuation_String ",m")" + . "${LIBS_HESTIA}/HestiaKERNEL/Trim_Right_String.sh" 1>&2 printf -- "%s\n" "$(HestiaKERNEL_Trim_Right_String "e你feeeff你你aerg aegE你F" "E你F")" . "${LIBS_HESTIA}/HestiaKERNEL/Trim_Left_String.sh"