DiscussionsIssue archiveOCCT:Foundation Classes

Archived issue #0026514

OSD_Path can not work with French symbols in file name.

Open CASCADEOCCT:Foundation Classesclosed11 public notes

Search issues

Description

If we have file like découverte.xml then OSD_Path raise an exception in OSD_Path::SetValues function. The Nam.IsAscii() returns Standard_False.

In other hand if we have TCollection_ExtendedString (aNameExt) with "découverte.xml" then the following command do nothing:
TCollection_AsciiString aName( aNameExt, '_' )
because IsAnAscii(c) function returns Standard_True in TCollection_AsciiString constructor.

Steps to reproduce

Public activity

11 archived notes

Participants are labeled by their role within this record.

01Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: User for GUITHARE project
Date: Mon Aug 3 20:02:20 2015 +0300

    0026514: OSD_Path can not work with French symbols in file name.
02Commenter 4
Patch author name is wrong, please fix it.
03Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
04Commenter 4
The patch is incorrect. Function IsAnAscii() accepts ExtCharacter (two-byte word) and returns True if it fits into one byte. It will always return True for char argument, thus method TCollection_AsciiString::IsAscii() will always return true.

By original intent, method IsAscii() indicates whether string contains only basic ASCII symbols (0-127), except control symbols (0-31). This perhaps needs revision.

Non-Ascii symbols, such as French letters, can be put to TCollection_AsciiString in two variants:

- as extended Ascii symbols, in current locale
- in UTF-8 encoding

Current convention is to use UTF-8 encoding. This allows storing any Unicode symbols in TCollection_AsciiString, and use it e.g. for work with file names. Most of OCCT functionality working with files (STEP, IGES, BREP reader/writers, etc.) already support this.

I propose the following approach:

- in OCCT: remove checks for IsAscii() from OSD_Path. Though some checks might be useful, they rather should be system-specific (e.g. check that file name does not contains punctuation symbols), it is unlikely worth doing that now.

- in your application: convert localized strings to UTF-8 before putting it to TCollection_AsciiString. When it is converted to ExtendedString, use MultiByte argument of constructor. If you are operate with files directly, consider using utility functions defined in OSD_File.hxx.
05Commenter 5
The problem is fixed inside DIAGRAM sources.
06Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: abv
Date: Thu Jan 7 21:15:29 2016 +0300

    0026514: OSD_Path can not work with French symbols in file name.
    
    Restriction on path to contain only basic ASCII symbols is removed in OSD_Path, to allow paths to contain any symbols (defined in UTF-8 encoding).
07Commenter 7
Fix pushed to CR26514, please review
08Commenter 4
Please test the patch. Test case is not needed.
09Commenter 9
Dear Commenter 1,

Branch CR26514_1 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MasOS: 134 (134 on master)
products component:
   Linux: 37 (37 on master)
   Windows: 0 (0 on master)

Regressions/Differences:
Not detected

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 90013297 / 89882677 [+0.15%]
Total CPU difference: 19205.690000000155 / 19263.900000000092 [-0.30%]

Testing on Windows:
Total MEMORY difference: 57211616 / 57466619 [-0.44%]
Total CPU difference: 17798.48169209903 / 18535.477216399115 [-3.98%]
10Commenter 3
Branch [archived branch] has been deleted by Commenter 4.

[revision removed]
11Commenter 3
Branch [archived branch] has been deleted by Commenter 4.

[revision removed]

Related records