Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to represent char in TypeSpec #3300

Open
3 tasks done
live1206 opened this issue May 8, 2024 · 2 comments
Open
3 tasks done

How to represent char in TypeSpec #3300

live1206 opened this issue May 8, 2024 · 2 comments
Labels
compiler:core Issues for @typespec/compiler design:needed A design request has been raised that needs a proposal triaged:core
Milestone

Comments

@live1206
Copy link

live1206 commented May 8, 2024

Clear and concise description of the problem

In swagger, we support char format here.

How are we going to represent char in TypeSpec

  • first-class type char
  • scalar
  • string with maximum length

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@timotheeguerin
Copy link
Member

We had this discussion last week,

Proposal was to have something like that

@minLength(1)
@maxLength(1)
scalar character extends string;

there was some concern about using char itself as the name as it can be a bit ambiguous in certain language

@bterlson
Copy link
Member

bterlson commented May 8, 2024

In particular, there is a question of whether we need one or all of:

  • char ala C/C++ where it's a byte, and can represent an ASCII character.
  • char ala C#/Java where it's 2 bytes, and can represent a UTF-16 code unit
  • char ala Rust/Go where it's 4 bytes, and can represent any Unicode scalar value

If you have any thoughts on this, please do share!

@markcowl markcowl added this to the Backlog milestone May 14, 2024
@markcowl markcowl added design:needed A design request has been raised that needs a proposal compiler:core Issues for @typespec/compiler triaged:core and removed needs-area labels May 14, 2024
@markcowl markcowl modified the milestones: Backlog, [2024] July May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler design:needed A design request has been raised that needs a proposal triaged:core
Projects
None yet
Development

No branches or pull requests

4 participants