Coder Social home page Coder Social logo

Comments (4)

KeenS avatar KeenS commented on June 8, 2024

Once wasabiz and I discussed what picrin's internal representation of unicode would be. There are some pros of UTF-8 and several cons of UTF-16 (or UTF-32).

  • As picrin is a lightweight implementation, memory consuming UTF-16 (or UTF-32) is not suitable.
  • wchar_t is specified to be at least 16bit width, that means you cannot use wchar_t to represent UTF-32
  • Because picrin uses ropes to hold strings, UTF-8's O(n) problem does not matter so much.

Thus remaining char and using UTF-8 will do, I think. How do you think @wasabiz ?

from picrin.

omasanori avatar omasanori commented on June 8, 2024

@KeenS Thank you. I agree with your opinion.

Some additions from my perspective:

  • Caching UTF-32 sequences may boost performance of character-oriented operations, at the cost of memory efficiency as @KeenS pointed out.
  • Strictly speaking, wchar_t is not for storing Unicode characters, but wide characters. The portable usage of wchar_t is treating it as an opaque type and not relying on its bit pattern.
    • Yes, the big three platforms all treat it as UTF-{16,32} code unit, but e.g. NetBSD doesn't.

from picrin.

nyuichi avatar nyuichi commented on June 8, 2024

@omasanori @KeenS

Sounds nice. I don't mind changing string internal representation unless it compiles on freestanding environment. UTF-32 sequence is good for programs doing heavy string modifications, but I think such a case is no more than 1% of the total. Providing a different structure is rational.

from picrin.

nyuichi avatar nyuichi commented on June 8, 2024

@omasanori @KeenS

Even if it breaks no-libc rule, if we can switch it off with macros, it'll probably be ok.

from picrin.

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.