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

There should be an easy way of declaring character codes. #2093

Closed
DartBot opened this issue Mar 9, 2012 · 4 comments
Closed

There should be an easy way of declaring character codes. #2093

DartBot opened this issue Mar 9, 2012 · 4 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Mar 9, 2012

This issue was originally filed by @ahmetaa


Currently defining a character code in Dart is not straight forward. An
example from http://www.dartlang.org/articles/io/ :

int semicolon = ';'.charCodeAt(0);

It is prety common to define or make comparisons with char codes in the code. Can there be an easier way of doing this in Dart?

@madsager
Copy link
Contributor

Added Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Apr 12, 2012

I think this is a library issue.


Removed Area-Language label.
Added Area-Library label.

@DartBot
Copy link
Author

DartBot commented Oct 5, 2012

This comment was originally written by @ahmetaa


Perhaps overloading [] operator for String can help this?

int c = 'a'[0];

@lrhn
Copy link
Member

lrhn commented Aug 23, 2013

The Library version is "x".codeUnitAt(0).
That's not going to be much easier. I think this is a language issue.

The alternative is to coopt some operator to give the same result as .codeUnitAt, e.g., "xy"(1) or "xy"/1. It's not going to be pretty. It can be made a compile-time constant, and may be defined to only work on single-character strings, so maybe even "x"() or ~"x" or -"x".

It needs spec work to guarantee that it's a compile-time constant, which we do need for switches and similar, so it might as well be done properly.

(The [] operator is already defined on string, and it returns a single code-unit string).


Removed Type-Defect, Area-Library labels.
Added Type-Enhancement, Area-Language, Duplicate labels.
Marked as being merged into #4415.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Aug 23, 2013
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
dart-bot pushed a commit that referenced this issue Mar 28, 2019
git log --oneline --no-decorate 3c060aae47985e9a248b850f1d0450304a5c97e3..8c363fe26f059c3063f1129adbb3c4e22a8ce954
8c363fe2 Restore default server for uploader command (#2102)
154a1419 Fix #28 -- escaping arguments as mentioned in TODO (#2093)
bb2b8b28 Remove validation for library file paths (#2067)


Change-Id: I795a8d58144003129b36e481b2693656035b2057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97638
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
copybara-service bot pushed a commit that referenced this issue Sep 21, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

ecosystem (https://github.com/dart-lang/ecosystem/compare/ed39318..dcf5c4f):
  dcf5c4f  2023-09-20  Parker Lougheed  Simplify dart_flutter_team_lints install instructions (#172)

http (https://github.com/dart-lang/http/compare/decefa6..1251619):
  1251619  2023-09-19  Brian Quinlan  Add the ability to control the URL cache. (#1020)

mockito (https://github.com/dart-lang/mockito/compare/412c0be..097e563):
  097e563  2023-09-19  Ilya Yanok  Add a missing dummy `bool` value

shelf (https://github.com/dart-lang/shelf/compare/e2a02b7..4851978):
  4851978  2023-09-20  Kevin Moore  shelf_router_generator: prepare to release v1.1.0 (#380)

test (https://github.com/dart-lang/test/compare/6449495..8191a35):
  8191a355  2023-09-20  Nate Bosch  Drop a TODO about running browser after compile (#2094)
  d8e9d87d  2023-09-18  Nate Bosch  Add a silent reporter (#2093)

tools (https://github.com/dart-lang/tools/compare/70d778d..3c248df):
  3c248df  2023-09-21  Devon Carew  misc infra updates for dart-lang/tools (#165)

Change-Id: I436a34847db75f45a20b8c18996419f88214485f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327280
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants