issue-#19 Externalize & Internalize
Posted: Wed Jul 08, 2015 2:53 am
I found, that Externalize & Internalize are not working correctly for Views and Models from modules with Cyrillic identifiers.
Compile this module, call commander bellow, save this view in a separate window and then try to open.Zinn wrote:Can you send me an example with a description of how to produced the error?
Code: Select all
MODULE ПроверкаОтображения;
IMPORT Views, Log, Stores, Ports;
TYPE
Отображение = POINTER TO RECORD (Views.View) END;
PROCEDURE (v: Отображение) Restore (f: Views.Frame; l, t, r, b: INTEGER);
BEGIN
f.DrawLine(l, t, r, b, 1, Ports.red)
END Restore;
PROCEDURE Deposit*;
VAR v: Отображение;
BEGIN
NEW(v);
Views.Deposit(v)
END Deposit;
END ПроверкаОтображения.
^Q "ПроверкаОтображения.Deposit; StdCmds.PasteView"
Agree!Josef Templ wrote:The bug is in the usage of ReadXString and WriteXString in module Stores.
Non-ASCII characters in a type name are thereby truncated to ASCII.
We have to use Utf8 conversion, I think.
I tried test version:Josef Templ wrote:The missing Utf-8 conversions have been added to Stores.
See the diffs at http://redmine.blackboxframework.org/pr ... 19cd8cc644.
- Josef
and the TextModels.Attributes.Internalize/Externalize need Utf-8 conversions in ReadXString/WriteXString for the font.typeface also.Josef Templ wrote:The missing Utf-8 conversions have been added to Stores.
Code: Select all
PROCEDURE (attr: Attributes) Internalize- (VAR rd: Stores.Reader), EXTENSIBLE;
(** pre: ~attr.init **)
(** post: attr.init **)
VAR
thisVersion: INTEGER;
fprint: INTEGER;
face: Fonts.Typeface;
size: INTEGER;
style: SET;
weight: INTEGER;
(*>>*)VAR buf:ARRAY 64 OF SHORTCHAR;res:INTEGER;(*<<*)
BEGIN
ASSERT(~attr.init, 20);
attr.init := TRUE;
attr.Internalize^(rd);
IF rd.cancelled THEN RETURN END;
rd.ReadVersion(minVersion, maxAttrVersion, thisVersion);
IF rd.cancelled THEN RETURN END;
rd.ReadInt(attr.color);
rd.ReadInt(fprint);
rd.ReadXString(face); (*>>*)buf:=SHORT(face$);Kernel.Utf8ToString(buf,face,res);(*<<*)
rd.ReadInt(size); rd.ReadSet(style); rd.ReadXInt(weight);
attr.font := Fonts.dir.This(face, size, style, weight);
IF attr.font.IsAlien() THEN Stores.Report("#System:AlienFont", face, "", "")
(*
ELSIF attr.font.Fingerprint() # fprint THEN Stores.Report("#System:AlienFontVersion", face, "", "")
*)
END;
rd.ReadInt(attr.offset)
END Internalize;
PROCEDURE (attr: Attributes) Externalize- (VAR wr: Stores.Writer), EXTENSIBLE;
(** pre: attr.init **)
VAR font: Fonts.Font;
(*>>*)VAR buf:ARRAY 64 OF SHORTCHAR;res:INTEGER;(*<<*)
BEGIN
ASSERT(attr.init, 20);
attr.Externalize^(wr);
wr.WriteVersion(maxAttrVersion);
wr.WriteInt(attr.color);
font := attr.font;
(*
wr.WriteInt(font.Fingerprint());
*)
wr.WriteInt(0);
(*>>*)Kernel.StringToUtf8(font.typeface,buf,res);(*<<*)
wr.WriteXString((*>>*)LONG(buf)(*font.typeface*)(*<<*));
wr.WriteInt(font.size); wr.WriteSet(font.style); wr.WriteXInt(font.weight);
wr.WriteInt(attr.offset)
END Externalize;