e3249d8e |
1 | puts "================" |
2 | puts "0030694: Data Exchange - support non-standard GB2312-encoded STEP files" |
3 | puts "" |
4 | puts "Test case:" |
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 "================" |
10 | puts "" |
11 | |
12 | proc fileToString { thePath } { |
13 | set aFile [open "$thePath" r] |
14 | set aText [read $aFile [file size "$thePath"]] |
15 | close $aFile |
16 | return $aText |
17 | } |
18 | |
19 | proc fileFromString { thePath theContent theCodePage } { |
20 | set aFile [open "$thePath" w] |
21 | fconfigure $aFile -translation lf -encoding "$theCodePage" |
22 | puts $aFile $theContent |
23 | close $aFile |
24 | } |
25 | |
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" |
31 | # 国标 |
32 | set aName [encoding convertfrom unicode "\xFD\x56\x07\x68"] |
33 | box b 1 2 3 |
34 | catch { Close A } |
35 | catch { Close T } |
36 | catch { Close U } |
37 | catch { Close G } |
38 | XNewDoc T |
39 | XAddShape T b 0 |
40 | XSetColor T b 1 0 0 |
41 | SetName T 0:1:1:1 "$aTmpNameTmpl" |
42 | GetName T 0:1:1:1 |
43 | WriteStep T "$aTmpFileTmpl" |
44 | |
45 | regsub -all -- $aTmpNameTmpl [fileToString "$aTmpFileTmpl"] "$aName" aContent |
46 | fileFromString "$aTmpFileUtf8" "$aContent" "utf-8" |
47 | fileFromString "$aTmpFileGb" "$aContent" "gb2312" |
48 | |
49 | param read.stepcaf.codepage UTF8 |
50 | ReadStep U "$aTmpFileUtf8" |
51 | ReadStep A "$aTmpFileGb" |
52 | param read.stepcaf.codepage GB |
53 | ReadStep G "$aTmpFileGb" |
54 | |
55 | if { [GetName U 0:1:1:1] != "$aName" } { puts "Error: unable to read UTF-8 STEP" } |
56 | if { [GetName G 0:1:1:1] != "$aName" } { puts "Error: unable to read gb2312 STEP" } |
57 | if { [GetName A 0:1:1:1] == "$aName" } { puts "Error: broken test case" } |