CharlesO
Strange behavior with strings
Is this the expected behavior for strings?
def rec_text do
# content of rec.txt
s = "ALTITUDE ENTERPRISES INT’L"
a = File.read!("rec.txt")
{a, s}
end
# Output
> X.rec_text
{"ALTITUDE ENTERPRISES INTÔÇÖL", "ALTITUDE ENTERPRISES INTÔÇÖL"}
# pasted directly into IEx it outputs correctly as expected
> "ALTITUDE ENTERPRISES INT’L"
"ALTITUDE ENTERPRISES INT'L"
>
No clue why this is happening.
Marked As Solved
fsa
Hi again - have you tried to google for conEmu - I am a little lost on this end, as my familiarity with this toolchain you are using is none-existing ![]()
ConEmu | Unicode Support seems to have relevant info…
you should maybe also check the console font you are using…
you could try to run chcp 65001 before you start iex…
… pester some devs running on windows(10)…!!! ![]()
Be brave and explore… just remember to note down what works, and what not… and take backups… ![]()
R.
Fridrik.
Also Liked
fsa
Hi - looks like something in your toolchain is tripping you up by interpreting the text file through codepage 858 - Code page 850 - Wikipedia
Your string quotation mark ( ’ ) is encoded in your file as hex e2 80 99 - which in code page 858 gives ÔÇÖ
Try to get your tool chain to respect UTF-8 - it displays correctly that way… you have my deepest sympathy - I have never touched windows 10 so can’t be of help there…
R.
Fridrik
fsa
Sebb
wow, how did you solve this case, detective? Have you memorized all code pages?
When you encode some text into a binary you have to use some encoding. For example you could have this codepage:
A = 01
B = 02
C = 03
so if you encode the text “ABBA” you’d get the binary 01020201
If you read this file, you need to know the encoding to decode it. If you use another codepage, eg this one:
1 = 01
2 = 02
3 = 03
this would read as 1221 - not what you want at all.
Last Post!
Sebb
glad it works now. But shouldn’t iex somehow communicate the encoding it wants to the shell?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









