Created
October 9, 2014 04:35
-
-
Save shino/986cc4300cc34bb95f76 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
% $R16B03_1_hipe/bin/erlc utf8_with_magic_comment.erl | |
% $R16B03_1_hipe/bin/erl -noshell -s utf8_with_magic_comment start -s init stop | |
===== format by 's' | |
[bytes]: あ | |
===== format by 'ts' | |
[codepoint]: \x{3042} | |
[bytes]: あ | |
[string_literal]: \x{3042} | |
===== format by 'ts' with io:setopts([{encoding, utf8}]) | |
[codepoint]: あ | |
[bytes]: ã | |
[string_literal]: あ |
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
%% -*- coding: utf-8 -*- | |
-module(utf8_with_magic_comment). | |
-compile(export_all). | |
start() -> | |
io:format(" ===== format by 's'~n"), | |
[catch io:format("[~s]: ~s~n", | |
[HowToCreate, hiragana_A(HowToCreate)]) || | |
HowToCreate <- [codepoint, bytes, string_literal]], | |
io:format(" ===== format by 'ts'~n"), | |
[catch io:format("[~s]: ~ts~n", | |
[HowToCreate, hiragana_A(HowToCreate)]) || | |
HowToCreate <- [codepoint, bytes, string_literal]], | |
io:format(" ===== format by 'ts' with io:setopts([{encoding, utf8}])~n"), | |
io:setopts([{encoding, utf8}]), | |
[catch io:format("[~s]: ~ts~n", | |
[HowToCreate, hiragana_A(HowToCreate)]) || | |
HowToCreate <- [codepoint, bytes, string_literal]]. | |
hiragana_A(codepoint) -> | |
[12354]; | |
hiragana_A(bytes) -> | |
[227,129,130]; | |
hiragana_A(string_literal) -> | |
"あ". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment