How do I reverse a String in Dart?

前端 未结 7 742
面向向阳花
面向向阳花 2021-02-03 20:13

I have a String, and I would like to reverse it. For example, I am writing an AngularDart filter that reverses a string. It\'s just for demonstration purposes, but it made me wo

相关标签:
7条回答
  • 2021-02-03 21:02

    The question is not well defined. Reversing arbitrary strings does not make sense and will lead to broken output. The first (surmountable) obstacle is Utf-16. Dart strings are encoded as Utf-16 and reversing just the code-units leads to invalid strings:

    var input = "Music \u{1d11e} for the win"; // Music                                                                     
    0 讨论(0)
提交回复
热议问题