Skip to main content



      Home
Home » Modeling » OCL » Unicode support
Unicode support [message #1733581] Mon, 30 May 2016 05:47 Go to next message
Eclipse UserFriend
Hi!

Does OCL support unicode?

Here is a simple test project:
https://github.com/AresEkb/ocl_unicode_test

It parses the following constraint contained in an UML model:
fullName.matches('[А-Яа-я]+')

After parsing unicode symbols become broken:
self.fullName.matches('[Рђ-РЇР°-СЏ]+')

Is there a workaround?
Re: Unicode support [message #1733584 is a reply to message #1733581] Mon, 30 May 2016 06:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi

Thanks. Excellent repro.

It should work. It clearly doesn't. Fix might be trivial. Might
conceivably fix it for RC3 today.

Workaround. Using \uxxxx might work, but it might share the same problem.

Regards

Ed Willink


On 30/05/2016 10:47, Denis Nikiforov wrote:
> Hi!
>
> Does OCL support unicode?
>
> Here is a simple test project:
> https://github.com/AresEkb/ocl_unicode_test
>
> It parses the following constraint contained in an UML model:
> fullName.matches('[А-Яа-я]+')
>
> After parsing unicode symbols become broken:
> self.fullName.matches('[Рђ-РЇР°-СЏ]+')
>
> Is there a workaround?
Re: Unicode support [message #1733588 is a reply to message #1733584] Mon, 30 May 2016 06:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The problem is that you have not declared your project "Text file
encoding". On my machine it therefore inherits Cp1252. If I set the
project to UTF-8 your example works much better.

If there is a problem, it is an Xtext issue, but I suspect it is
entirely your problem in accidentally developing a file with one
encoding then processing it with another. AFAIK Xtext (and so OCL)
should respect whatever consistent encoding you choose.

Regards

Ed Willink


On 30/05/2016 11:01, Ed Willink wrote:
> Hi
>
> Thanks. Excellent repro.
>
> It should work. It clearly doesn't. Fix might be trivial. Might
> conceivably fix it for RC3 today.
>
> Workaround. Using \uxxxx might work, but it might share the same problem.
>
> Regards
>
> Ed Willink
>
>
> On 30/05/2016 10:47, Denis Nikiforov wrote:
>> Hi!
>>
>> Does OCL support unicode?
>>
>> Here is a simple test project:
>> https://github.com/AresEkb/ocl_unicode_test
>>
>> It parses the following constraint contained in an UML model:
>> fullName.matches('[А-Яа-я]+')
>>
>> After parsing unicode symbols become broken:
>> self.fullName.matches('[Рђ-РЇР°-СЏ]+')
>>
>> Is there a workaround?
>
>
Re: Unicode support [message #1733593 is a reply to message #1733588] Mon, 30 May 2016 06:54 Go to previous messageGo to next message
Eclipse UserFriend
Thanks! It works, but it's a little bit strange.

There are two test cases in this file:
https://github.com/AresEkb/ocl_unicode_test/blob/master/src/ocl_unicode_test/Main.java

Test case 1:
            ExpressionInOCL expr = ocl.createInvariant(personAS, "fullName.matches('[А-Яа-я]+')");
            System.out.println("Expression: " + expr);

Test case 2:
            for (Constraint rule : person.getOwnedRules()) {
                ExpressionInOCL expr2 = getExpressionInOCL(ocl, rule);
                System.out.println("Expression: " + expr2);
            }

    public static ExpressionInOCL getExpressionInOCL(OCL ocl, Constraint constraint) throws ParserException
    {
        org.eclipse.ocl.pivot.Constraint asConstraint = ocl.getMetamodelManager().getASOf(org.eclipse.ocl.pivot.Constraint.class, constraint);
        return ocl.getSpecification(asConstraint);
    }


I understand why test case 1 starts working after I've changed default text encoding in the project settings. It was my fault.

But why project encoding affects test case 2? The OCL is read from the external file (model/My.uml), it's not hard-coded in Main.java... I guess that test case 2 must not depend on project settings...
Re: Unicode support [message #1733605 is a reply to message #1733593] Mon, 30 May 2016 07:56 Go to previous message
Eclipse UserFriend
Hi

On a good day, the embedded encoding within an XML file ensures that
it's characters are read correctly.

<?xml version="1.0" encoding="UTF-8"?>

Regards

Ed Willink

On 30/05/2016 11:54, Denis Nikiforov wrote:
> Thanks! It works, but it's a little bit strange.
>
> There are two test cases in this file:
> https://github.com/AresEkb/ocl_unicode_test/blob/master/src/ocl_unicode_test/Main.java
>
>
> Test case 1:
>
> ExpressionInOCL expr = ocl.createInvariant(personAS,
> "fullName.matches('[А-Яа-я]+')");
> System.out.println("Expression: " + expr);
>
> Test case 2:
>
> for (Constraint rule : person.getOwnedRules()) {
> ExpressionInOCL expr2 = getExpressionInOCL(ocl, rule);
> System.out.println("Expression: " + expr2);
> }
>
> public static ExpressionInOCL getExpressionInOCL(OCL ocl,
> Constraint constraint) throws ParserException
> {
> org.eclipse.ocl.pivot.Constraint asConstraint =
> ocl.getMetamodelManager().getASOf(org.eclipse.ocl.pivot.Constraint.class,
> constraint);
> return ocl.getSpecification(asConstraint);
> }
>
>
> I understand why test case 1 starts working after I've changed default
> text encoding in the project settings. It was my fault.
>
> But why project encoding affects test case 2? The OCL is read from the
> external file (model/My.uml), it's not hard-coded in Main.java... I
> guess that test case 2 must not depend on project settings...
Previous Topic:EMFtoCSP: Error in the ecl file
Next Topic:[oclinecore] import statement gets rewritten
Goto Forum:
  


Current Time: Tue Apr 29 18:35:12 EDT 2025

Powered by FUDForum. Page generated in 0.08525 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top