std-cptrans | ![]() |
(std-cptrans <string> <from-cp> <to-cp>)
Translates a string between two arbitrary valid codepages.
This is similar to the AutoCAD command DBTRANS which translates AutoCAD string entities betwen two codepages.
The translation is optimized for speed of subsequent STD-CPTRANS
calls. (On my system the similar function in DBTRANS.ARX is of about the same speed.)
A codepage is a table of ascii characters in a special and unique order, dependent on the system settings. Normally the AutoCAD system codepage (getvar "SYSCODEPAGE")
and the operating system codepage are the same, they don't need any translation. But sometimes you may want to maintain stringtables just in one codepage and automatically translate to to others. Or you may want to read in or write out strings in a different codepage.
Special treatment must be given to 8-bit extensions of foreign characters.
Codepage names may use common aliases. We support the aliases defined in DBTRANS.CPM and the aliases defined in the standard recode unix tool for all supported codepages. The name is a case-sensitive string!
All codepage names are unified to the names below.
The yet supported codepages are:
("iso8859-1" "ascii" "dos437" "dos850" "dos852" "dos855" "dos857" "dos860" "dos861" "dos863" "dos864" "dos865" "dos866" "dos869" "dos932" "iso8859-2" "iso8859-3" "iso8859-4" "iso8859-5" "iso8859-6" "iso8859-7" "iso8859-8" "iso8859-9" "ANSI_1251" "big5" "KSC5601" "mac-roman")
The stdlib standard codepage is "iso8859-1"
The cyrillic charset "koi8-r" and some others not used in AutoCAD itself are not defined in DBTRANS.CPM and we may think of how supporting and distributing other formats as well. Missing are also the 16-bit unicode codepages for asian languages like chinese, korean and japanese, unicode.
For a detailed list of valid aliases see here or STDLOCAL.LSP. For a list of all unified names you may also call (STD-%CODEPAGES
)
Exceptions
If a invalid codepage name or codepage alias is given to STD-SYS-CODEPAGE
an "invalid codepage" error is thrown. This might be a problem on dynamic codepage support. Therefore the special predicate STD-CODEPAGE-AVAILABLE-P
is provided.
string: A string
from-cp, to-cp: A string, which must be a valid codepage name, case-sensitive.
A string, the translated string.
It may search DBTRANS.CPM in the standard AutoCAD subdirectories and initializes some tables for faster processing of subsequent calls.
(std-require 'STDLOCAL)
Defined in STDLOCAL