Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tcl_script_is_latin_1

Paweł Salawa edited this page May 22, 2020 · 1 revision

Definition

Language: Tcl
Plugin for language: ScriptingTcl
How to use: Create custom SQL function. Suggested name: isLatin1
Function arguments only 1, a string
Function usage: SELECT isLatin1('text to test against Latin-1')
Description: Iterates through character in the string, checking if it's a Latin-1 or not. If all characters are in Latin-1 range, returns 1. If at least one character is outside of the range, returns 0.

Code

binary scan [lindex $argv 0] c* codes
foreach code $codes {
 # Fail if code is outside of ranges: 32-126, 160-256
 if {$code < 32 || $code > 126 && $code < 160 || $code > 256} {
 return 0
 }
}
return 1

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /