Text functions: convert Instructions: convertconvert <text_var> from|to <encoding>
Text functions: convert Instructions: convertConvert Data Types: Text Item selector "[]": Text Glossary: text, text_valtext from Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or to named encoding.
Flow control: if … then Flow control: try … thenThe Data Types: Text Item selector "[]": Text Glossary: text, text_valtext Glossary: Variable, var_refvariable is overwritten with Flow control: if … then Flow control: try … thenthe result of Flow control: if … then Flow control: try … thenthe conversion. Flow control: if … then Flow control: try … thenThe <encoding> must be a Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername, Operators: Bitwise Not "~" Operators: Boolean Negation "!"not a Glossary: text, text_valtext value. List functions: thisThis means: just Instructions: writewrite Flow control: if … then Flow control: try … thenthe nickname here.
e.g.:
Text functions: convert Instructions: convertconvert mytext to printable;
Text functions: convert Instructions: convertconvert mytext to mac_roman;
Text functions: convert Instructions: convertconvert mytext from html;
Instructions: putput "http://", Text functions: convert Instructions: convertconvert(mytext to url)
Flow control: if … thenIf you need calculated encodings, you may use Vipsi command syntax: Operators Operators Glossary: Operatoroperator @ to Text functions: convert Instructions: convertconvert a Data Types: Text Item selector "[]": Text Glossary: text, text_valtext to a Vipsi command syntax: Identifiers (names) Identifiers, names Operators: Make Identifier "@" Text functions: name Glossary: Name, Identifiername:
Instructions: var How does VScript::Value() work?: Var*&var myEncoding = "Constants: tabtab" # myTabWidth
Text functions: convert Instructions: convertconvert myText to @(myEncoding);
Take care that you Flow control: do … loopdo no double conversion!
Converting to a certain character set Text functions: convert Instructions: convertconverts Flow control: if … then Flow control: try … thenthe Data Types: Text Item selector "[]": Text Glossary: text, text_valtext to Integer numbers: Binary Floating point: Binary Text functions: binstrbinary data with all characters being bytes in range [0 .. 255], suitable for writing to Text functions: file Instructions: filefile Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or stream in Integer numbers: Binary Floating point: Binary Text functions: binstrbinary mode.
Converting from a certain character set expects Flow control: if … then Flow control: try … thenthe Data Types: Text Item selector "[]": Text Glossary: text, text_valtext to be Integer numbers: Binary Floating point: Binary Text functions: binstrbinary data with all characters being bytes in range [0 .. 255], as Instructions: readread in Integer numbers: Binary Floating point: Binary Text functions: binstrbinary mode from a Text functions: file Instructions: filefile Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or stream.
Converting a Data Types: Text Item selector "[]": Text Glossary: text, text_valtext to a certain character set an Flow control: if … then Flow control: try … thenthen writing it with Instructions: putput to a Text functions: file Instructions: filefile Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or stream, is certainly an error, because Instructions: putput most likely also performs a convert: Character set conversions: convert: Character set conversions:character set conversion, by default to UTF-8. After having converted a character set by hand you must Instructions: writewrite Flow control: if … then Flow control: try … thenthe data in Integer numbers: Binary Floating point: Binary Text functions: binstrbinary mode, without any further conversion, e.g. with Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction Instructions: writewrite Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or using Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction Text functions: file Instructions: filefile.
Flow control: if … then Flow control: try … thenThe same is true for reading with Instructions: getget Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and converting Flow control: if … then Flow control: try … thenthe Instructions: readread Data Types: Text Item selector "[]": Text Glossary: text, text_valtext from a certain character set, because Instructions: getget has most likely already performed a convert: Character set conversions: convert: Character set conversions:character set conversion, by default from UTF-8. Flow control: if … thenIf you want to Text functions: convert Instructions: convertconvert Flow control: if … then Flow control: try … thenthe data by hand you must Instructions: readread it in Integer numbers: Binary Floating point: Binary Text functions: binstrbinary mode, e.g. with Vipsi command syntax: Instructions Instructions Glossary: Instructioninstruction Instructions: readread Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Vipsi command syntax: Functions Functions Glossary: Functionfunction Text functions: file Instructions: filefile.
e.g. UCS-4:
Converting Data Types: Text Item selector "[]": Text Glossary: text, text_valtext to UCS-4 expands each character to 4 characters, each representable in 1 byte, suitable for writing in Integer numbers: Binary Floating point: Binary Text functions: binstrbinary mode to a Text functions: file Instructions: filefile e.g. with Instructions: writewrite.
Converting Data Types: Text Item selector "[]": Text Glossary: text, text_valtext from UCS-4 combines every 4 characters into one character, assuming that Flow control: if … then Flow control: try … thenthe source Data Types: Text Item selector "[]": Text Glossary: text, text_valtext only contains bytes e.g. Instructions: readread in Integer numbers: Binary Floating point: Binary Text functions: binstrbinary mode with Instructions: readread.
Instructions: var How does VScript::Value() work?: Var*&var a = Text functions: file Instructions: filefile "filename" Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and Text functions: file Instructions: filefile "filename" = a also Instructions: readread/Instructions: writewrite Integer numbers: Binary Floating point: Binary Text functions: binstrbinary data Operators: Boolean And with Variable "&&=" Operators: Bitwise And with Variable "&=" Operators: Bitwise And "&" Operators: Boolean And "&&"and are suitable targets for a by-hand conversion.
Instructions: getget Operators: Boolean Or with Variable "||=" Operators: Bitwise Or with Variable "|=" Operators: Bitwise Or "|" Operators: Boolean Or "||"or Instructions: putput already perform a conversion from|to UTF-8 (may be changed with Functions with varying return types: ioctl Instructions: ioctlioctl - Operators: Bitwise Not "~" Operators: Boolean Negation "!"not yet implemented in version 0.8.7). Applying a conversion after reading with Instructions: getget / before writing with Instructions: putput without having disabled any conversion is certainly an error.
|