Last active
May 4, 2017 11:55
-
-
Save hakanai/28159914861f07bca7d18e3ae603516b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ iex | |
| Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] | |
| Interactive Elixir (1.4.2) - press Ctrl+C to exit (type h() ENTER for help) | |
| iex(1)> String.slice("cafe\u0301", 0..3) | |
| "café" | |
| iex(2)> String.slice("cafe\u0301", 0..2) | |
| "caf" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cat > Cafe.java | |
| import java.text.BreakIterator; | |
| import java.util.Locale; | |
| class Cafe { | |
| public static void main(String[] args) { | |
| String str = "cafe\u0301"; | |
| System.out.println(str); | |
| System.out.println("Using substring:"); | |
| System.out.println(str.substring(0, 4)); | |
| System.out.println("Using BreakIterator:"); | |
| BreakIterator iterator = BreakIterator.getCharacterInstance(Locale.ROOT); | |
| iterator.setText(str); | |
| int start = iterator.first(); | |
| int end = iterator.next(4); | |
| System.out.println(str.substring(start,end)); | |
| } | |
| } | |
| $ javac Cafe.java | |
| $ java Cafe | |
| café | |
| Using substring: | |
| cafe | |
| Using BreakIterator: | |
| café |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ python | |
| Python 2.7.11 (default, Oct 18 2016, 15:17:18) | |
| [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| >>> u'cafe\u0301'[:4] | |
| u'cafe' | |
| >>> import textwrap | |
| >>> textwrap.wrap(u'e\u0301e\u0301e\u0301', 3) | |
| [u'e\u0301e', u'\u0301e\u0301'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ python3 | |
| Python 3.5.1 (default, Feb 22 2016, 11:23:19) | |
| [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| >>> u'cafe\u0301'[:4] | |
| 'cafe' | |
| >>> import textwrap | |
| >>> textwrap.wrap(u'e\u0301e\u0301e\u0301', 3) | |
| ['ée', '́é'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ irb | |
| irb(main):001:0> RUBY_VERSION | |
| => "2.0.0" | |
| irb(main):002:0> "cafe\u0301"[0..3] | |
| => "cafe" | |
| irb(main):003:0> "cafe\u0301".chars | |
| => ["c", "a", "f", "e", "́"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ irb | |
| irb(main):001:0> RUBY_VERSION | |
| => "2.4.0" | |
| irb(main):002:0> "cafe\u0301"[0..3] | |
| => "cafe" | |
| irb(main):003:0> "cafe\u0301".chars | |
| => ["c", "a", "f", "e", "́"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ cat > cafe.rs | |
| fn main() { | |
| let s = "cafe\u{0301}"; | |
| println!("{}", s); | |
| let slice = &s[..4]; | |
| println!("{}", slice); | |
| } | |
| $ rustc cafe.rs | |
| $ ./cafe | |
| café | |
| cafe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Welcome to Apple Swift version 3.1 (swiftlang-802.0.51 clang-802.0.41). Type :help for assistance. | |
| 1> String("cafe\u{0301}".characters.prefix(4)) | |
| $R0: String = "café" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment