File: encoding.tcl

package info (click to toggle)
alicq 0.6.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 412 kB
  • ctags: 195
  • sloc: tcl: 2,703; makefile: 39
file content (29 lines) | stat: -rw-r--r-- 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#  Alicq ICQ client: encoding module
#  Copyright (C) Ihar Viarheichyk 2001

#  This module is a part of Alicq ICQ client.

proc GetEncoding {name1 name2 op} {
	upvar 1 $name1 encoding
	# Default value is system encoding
	set encoding [encoding system]
	# Use encodings beginnig with CP on the wire
	if {[string match cp* $encoding]} return
	# Trying find wire encoding by the list
	foreach {local wire} {{koi8-r koi8-u iso8859-5} cp1251} {
		if {[lsearch -exact $local $encoding]!=-1} {
			set encoding $wire 
			return
		}
	}
	# If previuos attempts failed, analyse LANG variable
	# (usefull for UTF-8 encoding
	if {[info exists ::env(LANG)]} {
		switch -regex $::env(LANG) {
			"^(be|ru|ua)_" 	{set encoding "cp1251" }
		}
	}
}

trace variable ::encoding r encoding::GetEncoding