-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
188 additions
and
1 deletion.
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,55 @@ | ||
#!/bin/bash | ||
|
||
|
||
|
||
function LOG_ERROR() | ||
{ | ||
local content=${1} | ||
echo -e "\033[31m"${content}"\033[0m" | ||
} | ||
|
||
function LOG_INFO() | ||
{ | ||
local content=${1} | ||
echo -e "\033[32m"${content}"\033[0m" | ||
} | ||
|
||
get_md5sum_cmd() { | ||
local md5sum_cmd="md5sum" | ||
if [ "$(uname)" == "Darwin" ]; then | ||
md5sum_cmd="md5" | ||
fi | ||
echo "$md5sum_cmd" | ||
} | ||
|
||
function checkConcatenatedRareString() { | ||
|
||
concatenatedString=${1} | ||
log_file=${2} | ||
md5sum_cmd=$(get_md5sum_cmd) | ||
|
||
md5_concatenatedString=$(echo -n "$concatenatedString" | $md5sum_cmd | awk '{print $1}') | ||
|
||
# compare rare string and stringFromGet | ||
get_output=$(cat ${log_file}| grep "result=" | awk -F '[][]' '{print $4}' | awk NF | tail -n 1) | ||
stringFromGet=$(echo "$get_output" | grep "Return values" | sed 's/Return values:\(.*\)/\1/' | tr -d '()') | ||
md5_stringFromGet=$(echo -n "$stringFromGet" | $md5sum_cmd | awk '{print $1}') | ||
if [ "$md5_concatenatedString" != "$md5_stringFromGet" ]; then | ||
LOG_ERROR "error: check failed, the md5 values of rareString and stringFromGet are not equal, fail concatenatedString: ${concatenatedString}" | ||
exit 1 | ||
else | ||
LOG_INFO "check success, concatenatedString: ${concatenatedString}" | ||
fi | ||
} | ||
|
||
main() { | ||
concatenatedString=${1} | ||
log_file=${2} | ||
LOG_INFO "check rare string start, concatenatedString: ${concatenatedString}" | ||
|
||
checkConcatenatedRareString ${concatenatedString} ${log_file} | ||
LOG_INFO "check rare string finished!" | ||
} | ||
|
||
main "$@" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
rare_str_range_names=("CJKUnifiedIdeographs" "CJKCompatibilityIdeographs" "CJKCompatibilityIdeographsSupplement" "KangxiRadicals" "CJKRadicalsSupplement" "IdeographicDescriptionCharacters" "Bopomofo" "BopomofoExtended" "CJKStrokes" "CJKSymbolsandPunctuation" "CJKCompatibilityForms" "CJKCompatibility" "EnclosedCJKLettersandMonths" "CJKUnifiedIdeographsExtensionA" "CJKUnifiedIdeographsExtensionB" "CJKUnifiedIdeographsExtensionC" "CJKUnifiedIdeographsExtensionD" "CJKUnifiedIdeographsExtensionE" "CJKUnifiedIdeographsExtensionF") | ||
rare_str_range_values=("19968,40959" "63744,64255" "194560,195103" "12032,12255" "11904,12031" "12272,12287" "12544,12591" "12704,12735" "12736,12783" "12288,12351" "65072,65103" "13056,13311" "12800,13055" "13312,19903" "131072,173791" "173824,177977" "177984,178205" "178208,183969" "183984,191456") | ||
final_rare_input="" | ||
|
||
LOG_INFO() { | ||
local content=${1} | ||
echo -e "\033[32m[INFO] ${content}\033[0m" | ||
} | ||
|
||
LOG_ERROR() { | ||
local content=${1} | ||
echo -e "\033[31m[ERROR] ${content}\033[0m" | ||
} | ||
|
||
download_rare_string_jar() { | ||
LOG_INFO "----- Downloading get-rare-string-with-unicode.jar -------" | ||
curl -LO "https://github.com/FISCO-BCOS/LargeFiles/raw/master/binaries/jar/get-rare-string-with-unicode.jar" | ||
} | ||
|
||
getRangeValues() { | ||
local rangeValue=$1 | ||
IFS=',' read -r startValue endValue <<<"$rangeValue" | ||
|
||
echo "$startValue $endValue" | ||
} | ||
|
||
getConcatenatedRareStringWithRange() { | ||
local startUnicode=${1} | ||
local endUnicode=${2} | ||
|
||
# concatenate strings with begin middle end | ||
local concatenatedString | ||
concatenatedString=$(java -cp './get-rare-string-with-unicode.jar' org.example.Main ${startUnicode}) | ||
local midUnicode=$((($startUnicode + $endUnicode) / 2)) | ||
for ((i = midUnicode; i <= midUnicode + 5; i++)); do | ||
local currentRareString | ||
currentRareString=$(java -cp './get-rare-string-with-unicode.jar' org.example.Main ${i}) | ||
concatenatedString+="$currentRareString" | ||
done | ||
local endRareString | ||
endRareString=$(java -cp './get-rare-string-with-unicode.jar' org.example.Main ${endUnicode}) | ||
concatenatedString+="$endRareString" | ||
echo "$concatenatedString" | ||
} | ||
|
||
get_rare_string() { | ||
download_rare_string_jar | ||
export LC_ALL=en_US.UTF-8 | ||
export LANG=en_US.UTF-8 | ||
export LANGUAGE=en_US.UTF-8 | ||
|
||
for ((i = 0; i < ${#rare_str_range_names[@]}; i++)); do | ||
range_name="${rare_str_range_names[$i]}" | ||
range_value="${rare_str_range_values[$i]}" | ||
|
||
read -r start_value end_value <<<$(getRangeValues "${range_value}") | ||
concatenated=$(getConcatenatedRareStringWithRange $start_value $end_value) | ||
final_rare_input+="${concatenated}" | ||
done | ||
} | ||
|
||
main() { | ||
get_rare_string | ||
echo "${final_rare_input}" | ||
} | ||
|
||
main |