Unicode support [message #1733581] |
Mon, 30 May 2016 05:47  |
Eclipse User |
|
|
|
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 #1733605 is a reply to message #1733593] |
Mon, 30 May 2016 07:56  |
Eclipse User |
|
|
|
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...
|
|
|
Powered by
FUDForum. Page generated in 0.08525 seconds