Recent

Author Topic: Firebird / ANSI vs UTF-8  (Read 5387 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
Firebird / ANSI vs UTF-8
« on: November 14, 2010, 11:56:37 am »
sqdb.sql.text:= 'create table tb1 (id varchar (10) , wrd varchar (700))';
sqdb.ExecSQL;
trdb.CommitRetaining;                                                   
.........................................................
readln(dottxt,ln);
eflowmm.Append(ansitoutf8(ln));
lns:= lns + 1;
osq.sql.text:= 'insert into tb1 values (' +inttostr(lns)+','+ ansitoutf8(ln)+')';

'ansitoutf8' worked well added to TMemo(eflowmm).
But why didn't work for Firebird?
Lazarus 1.2.4 / Win 32 / THAILAND

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 171
    • http://www.jvdw.nl
Re: Firebird / ANSI vs UTF-8
« Reply #1 on: November 14, 2010, 12:04:38 pm »
Maybe:

osq.sql.text:=

'insert into tb1 values (' +inttostr(lns)+','+ quotedstr(ansitoutf8(ln))+')';

john

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: Firebird / ANSI vs UTF-8
« Reply #2 on: November 14, 2010, 12:29:50 pm »
OMG  :D ,

It worked perfectly. Thank you so much.

One more question please.
Initially that ANSI text file was a xml file before and it was such a big big file.
For I'm an idiot to xml knowledge, so I opened it with Notepad and saved it as an ANSI textfile.

Is it possible to read the xml file line by line like I did with this text file?
var
dottxt : textfile; And how to change this line?
Lazarus 1.2.4 / Win 32 / THAILAND

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 171
    • http://www.jvdw.nl
Re: Firebird / ANSI vs UTF-8
« Reply #3 on: November 14, 2010, 12:39:09 pm »

Beware that an XML-file does not need line-endings. They may be there, for readability as a textfile, but don't take that for granted.

So it could be that a readln reads more then a xml-line, a block or even the complete file.

I think there are some handy units or components out there that can help you extracting data from XML. Search for XML and parsing.

Or look here: http://wiki.lazarus.freepascal.org/XML_Tutorial

John

asdf

  • Sr. Member
  • ****
  • Posts: 310
Re: Firebird / ANSI vs UTF-8
« Reply #4 on: November 15, 2010, 03:20:00 am »
ReadXMLFile(DocA, FileNameEdit1.Text);

What shold be edited for this line if that xml file is ANSI?
Lazarus 1.2.4 / Win 32 / THAILAND

 

TinyPortal © 2005-2018