[Gambas-user] Problem with Conv() and XmlWrite

Benoit Minisini gambas at ...1...
Mon Dec 22 20:47:34 CET 2008


On lundi 22 décembre 2008, Luigi Carlotto wrote:
> > If you are sure that your strings are ASCII, why doing
> > Conv(TheString, "UTF-8", "ASCII")?
>
> Yes!

The question was "why?"

>
> > And the error message printed by the underlying iconv library is
>
> clear: your
>
> > string is not ASCII.
>
> No (see result)!
>
> > According to you, The toString() methods always returns an accurate
>
> string.
> Yes!
>
> > According to the source code, Conv() receives a non-ascii string.
>
> No!
>
> > Can you check that, by splitting your code?
> >
> > FOR EACH oItem IN oGroup.Items
> > sType = oItem.toString()
> > sType = Conv(sType, "UTF-8", "ASCII")
> > oXml.Attribute(oItem.Name, sType)
> > NEXT
>
> Result:
>
> ...
> 150    FOR EACH oItem IN oGroup.Items
> 151      sType = oItem.toString()
> 152      PRINT sType
> 153      sType = Conv(sType, "UTF-8", "ASCII")
> 154      oXml.Attribute(oItem.Name, sType)
> 155    NEXT
> ...
>
> sType="ACTION,ADD,ALL,ALTER,ANALYZE,AND,AS,ASC,ASENSITIVE,BEFORE,BETWEEN,BI
>GINT,BINARY,BIT,BLOB,BOTH,BY,CALL,CASCADE,CASE,CHANGE,CHAR,CHARACTER,CHECK,C
>OLLATE,COLUMN,CONDITION,CONNECTION,CONSTRAINT,CONTINUE,CONVERT,CREATE,CROSS,
>CURRENT_DATE,CURRENT_TIME,CURRENT_TIMESTAMP,CURRENT_USER,CURSOR,CURSOR
> DATABASE,DATABASES,DATE,DAY_HOUR,DAY_MICROSECOND,DAY_MINUTE,DAY_SECOND,DEC,
>DECIMAL,DECLARE,DEFAULT,DELAYED,DELETE,DESC,DESCRIBE,DETERMINISTIC,DISTINCT,
>DISTINCTROW,DIV,DOUBLE,DROP,DUAL,EACH,ELSE,ELSEIF,ENCLOSED,ENUM,ESCAPED,EXIS
>TS,EXIT,EXPLAIN,FALSE,FETCH,FLOAT,FLOAT4,FLOAT8,FOR,FORCE,FOREIGN,FROM,FULLT
>EXT,GOTO,GRANT,GROUP,HAVING,HIGH_PRIORITY,HOUR_MICROSECOND,HOUR_MINUTE,HOUR_
>SECOND,IF,IGNORE,IN,INDEX,INFILE,INNER,INOUT,INSENSITIVE,INSERT,INT,INT1,INT
>2,INT3,INT4,INT8,INTEGER,INTERVAL,INTO,IS,ITERATE,JOIN,KEY,KEYS,KILL,LABEL,L
>EADING,LEAVE,LEFT,LIKE,LIMIT,LINES,LOAD,LOCALTIME,LOCALTIMESTAMP,LOCK,LONG,L
>ONGBLOB,LONGTEXT,LOOP,LOW_PRIORITY,MATCH,MEDIUMBLOB,MEDIUMINT,MEDIUMTEXT,MID
>DLEINT,MINUTE_MICROSECOND,MINUTE_SECOND,MOD,MODIFIES,NATURALNOT,NO,NO_WRITE_
>TO_BINLOG,NULL
> NUMERIC,ON,OPTIMIZE,OPTION,OPTIONALLY,OR,ORDER,OUT,OUTER,OUTFILE,PRECISION,
>PRIMARY,PROCEDURE,PURGE,READ,READS,REAL,REFERENCES,REGEXP,RELEASE,RENAME,REP
>EAT,REPLACE,REQUIRE,RESTRICT,RETURN,REVOKE,RIGHT,RLIKE,SCHEMA,SCHEMAS,SECOND
>_MICROSECOND,SELECT,SENSITIVE,SEPARATOR,SET,SHOW,SMALLINT,SONAME,SPATIAL,SPE
>CIFIC,SQL,SQLEXCEPTION,SQLSTATE,SQLWARNING,SQL_BIG_RESULT,SQL_CALC_FOUND_ROW
>S,SQL_SMALL_RESULT,SSL STARTING,STRAIGHT_JOIN,TABLE
> TERMINATED,TEXT,THEN,TIME,TIMESTAMP,TINYBLOB,TINYINT,TINYTEXT,TO,TRAILING,T
>RIGGER,TRUE,UNDO,UNION,UNIQUE,UNLOCK,UNSIGNED,UPDATE,UPGRADE,USAGE,USE,USING
>,UTC_DATE,UTC_TIME,UTC_TIMESTAMP,VALUES,VARBINARY,VARCHAR,VARCHARACTER,VARYI
>NG,WHEN,WHERE,WHILE,WITH,WRITE,XOR,YEAR_MONTH,ZEROFILL" Error: Error writing
> XML data
> Code: -1
> Class: pgConfig
> Where: pgConfig.Save.154
>
> As you can see, the error not verification in the conversion, but in the
> writing on XML, and the string “sType” (too long...) contains alone
> characters ASCII.
>

Why don't you have the same error as in your first post?

Does the sType string have newlines inside?

-- 
Benoit Minisini




More information about the User mailing list