GithubHelp home page GithubHelp logo

Unicode normalization of content about atjson HOT 1 OPEN

condenast avatar condenast commented on August 23, 2024
Unicode normalization of content

from atjson.

Comments (1)

blaine avatar blaine commented on August 23, 2024

atjson currently uses UTF-16 code points per the ecmascript String type, so unicode-equivalent texts that use different unicode normalization (or unnormalized texts) are treated as entirely separate documents.

There are a couple of different possible ways to address this, but in practice, as long as text editors or tools using atjson do not normalize the content (or do so only using the insertText and deleteText methods), the system is internally consistent and specifying behaviour for this is unnecessary.

For an interchange format where the underlying text might be subject to modification independently from the annotations, or environments where it's necessary or desirable to normalize the unicode content string without using the atjson interface (I'm not sure I can think of a realistic example, but happy for suggestions!), one possible approach would be to add a new contentMimeType document attribute (or similar). This could be used to specify the mime-type of the content (and give a path to automatic handling of normalization, string offset behaviours, etc). One challenge with this approach is that while it's possible to specify a charset in addition to text/plain (e.g. "text/plain; charset=UTF-16") per RFC2231, I'm not aware of any standardized way to specify unicode normalization in a content type (my understanding is that charset in mime types must be one of the IANA registered types, none of which include normalization approaches)

That all said, so long as software that modifies an atjson document ensures that (1) the offsets align to UTF-16 code points per the ecmascript definition of strings and (2) any changes, e.g. unicode normalization, correctly update the offsets to account for any added or removed code points, then any other software operating on an atjson document would be able to correctly interpret and modify that document itself.

In practical terms, the insertion or removal of a single code point via a normalization process would simply increase or reduce by one all annotation offsets greater than the insertion offset.

The more complex case of normalization of a document with annotations that refer to code points within a composed character (i.e., grapheme) that is modified by normalization is an edge case that might warrant consideration, though we haven't yet encountered that use-case. My hunch is that any annotations that have start/end offsets within a unicode grapheme (i.e., not aligned to the start or end of the grapheme) would be unicode-specific annotations and as such could use the custom text insertion/deletion behaviours in order to implement the correct behaviour.

from atjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.