1 puts "================"
2 puts "0030694: Data Exchange - support non-standard GB2312-encoded STEP files"
5 puts "1) Creates a temporary STEP file-template using WriteStep."
6 puts "2) Reads generated template and replaces @tmp_name@ entity in it with Simplified Chinese characters using Tcl."
7 puts "3) Generates 2 STEP files in UTF-8 and GB2312 encodings (converted by Tcl)."
8 puts "4) Reads generated files using StepRead and validates entity name."
9 puts "================"
12 proc fileToString { thePath } {
13 set aFile [open "$thePath" r]
14 set aText [read $aFile [file size "$thePath"]]
19 proc fileFromString { thePath theContent theCodePage } {
20 set aFile [open "$thePath" w]
21 fconfigure $aFile -translation lf -encoding "$theCodePage"
22 puts $aFile $theContent
26 pload XDE OCAF MODELING VISUALIZATION
27 set aTmpNameTmpl "@tmp_name@"
28 set aTmpFileTmpl "${imagedir}/${casename}-tmp.stp"
29 set aTmpFileUtf8 "${imagedir}/${casename}-tmp-utf8.stp"
30 set aTmpFileGb "${imagedir}/${casename}-tmp-gb.stp"
32 set aName [encoding convertfrom unicode "\xFD\x56\x07\x68"]
38 SetName T 0:1:1:1 "$aTmpNameTmpl"
40 WriteStep T "$aTmpFileTmpl"
42 regsub -all -- $aTmpNameTmpl [fileToString "$aTmpFileTmpl"] "$aName" aContent
43 fileFromString "$aTmpFileUtf8" "$aContent" "utf-8"
44 fileFromString "$aTmpFileGb" "$aContent" "gb2312"
46 param read.step.codepage UTF8
47 ReadStep U "$aTmpFileUtf8"
48 ReadStep A "$aTmpFileGb"
49 param read.step.codepage GB
50 ReadStep G "$aTmpFileGb"
52 if { [GetName U 0:1:1:1] != "$aName" } { puts "Error: unable to read UTF-8 STEP" }
53 if { [GetName G 0:1:1:1] != "$aName" } { puts "Error: unable to read gb2312 STEP" }
54 if { [GetName A 0:1:1:1] == "$aName" } { puts "Error: broken test case" }