reading text as a binary format

testfile.OPEN(‘C:\Wr\utf8.txt’);

testfile.CREATEINSTREAM(StreamInObj);

StreamInObj.READ(Txt);

MESSAGE(Txt + '\Size: ’ + FORMAT(Int));

testfile.CLOSE();

I am trying to read text from a file in binary format. but it shows error in StreamInObj.READ(Txt); here.

help me.

what error message you are getting?

did you try with

StreamInObj.READTEX|T(Txt); ?

this show the following error The stream cannot find a zero-terminated string. The stream may be invalid, or the variable or requested) size may be too small.


when i try with StreamInObj.READTEX|T(Txt); , it is working file.

but i want as like following.
example: i want to read data as a binary formt as like : ef bb bf b1 83 90 e1 83 91 e1 83 92 (utf8 format)

after reading this utf8 format, i will convert it to ascii format.

I need this because when i export xml file to nav, it cannot convert utf8 text in nav.

Actaully, i want to read this from a xml file and then i want to convert it to ascii format.

this is the problem of utf8 character. i am working with kartoli. so, we have some utf8 character and microsoft navision cannot convert this.

hello, i have done this for georgian character. it can convert georgian utf8 character to ascii character from text file.

but i need this for xml file.

FieldSeparator := ‘|’;

FOR Position := 1 TO STRLEN(UniCode) DO BEGIN
Token := UniCode[Position];
Char := Token;
DummyInt := Char;
CASE Char OF
225: BEGIN

ExtractString:=ExtractString+ FORMAT(Token);

END;

131: BEGIN
ExtractString:=ExtractString+ FORMAT(Token);

END;

144: BEGIN

////////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=192;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////////

END;

145:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=193;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
146:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=194;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;

147:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=195;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
148:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=196;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
149:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=197;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
150:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=198;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;

151:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=200;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
152:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=201;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
153:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=202;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
154:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=203;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;

155:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=204;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
156:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=205;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
157:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=207;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
158:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=208;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;

159:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=209;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
160:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=210;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
161:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=211;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
162:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=212;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
163:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=214;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
164:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=215;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;

165:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=216;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
166:BEGIN
//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=217;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
167:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=218;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
168:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=219;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;

169:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=220;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
170:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=221;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
171:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=222;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
172:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=223;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
173:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=224;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
174:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=161;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;

175:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=227;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
176:BEGIN

//////////
Counter:=UTF8FormatCheck( ExtractString);
IF Counter=2 THEN BEGIN
Char:=228;
ASCII:= ASCII+ FORMAT( Char);

WriteOnFile;

END;
/////////

END;
END;
////////////////
END;
Exportfile.WRITE(ASCII);
CLEAR(ASCII);

Integer - OnPostDataItem()
MESSAGE(‘ASCII-Codes for conversion\could now be found in\’+Exportfile.NAME);
Exportfile.CLOSE;

UTF8FormatCheck(InputString : Text[1024]) : Integer
FOR j := 1 TO STRLEN(InputString) DO BEGIN
Char2 := InputString[j];
DInt := Char2;
IF( DInt=225) THEN BEGIN
Counter2 := Counter2 + 1;

END;

IF( DInt=131) THEN BEGIN
Counter2 := Counter2 + 1;

END;

END;
EXIT( Counter2);

WriteOnFile()
// Exportfile.WRITE(ASCII);
CLEAR(ExtractString);
// CLEAR(ASCII);
CLEAR(Counter);