How do I reverse a String in Dart?

前端 未结 7 740
面向向阳花
面向向阳花 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 

提交回复
热议问题