CharlesO

CharlesO

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.

Showing Posts 1 to 10

Sebb

Sebb

The string s should be output correctly, maybe your terminal is not using U8 codepage? Are you on windows? As for a - depends on the encoding of the file.

CharlesO

CharlesO OP

I’m on Windows 10, I’m using Windows Terminal + conEmu.

the troubling bit is when I pass the same to ODBC I get an error. so it’s not just the screen output, it’s the actual value

Sebb

Sebb

What is the encoding of the source-file?

CharlesO

CharlesO OP

fsa

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

CharlesO

CharlesO OP

@fsa from what you are saying, the console display will be wrong as expected, but the underlying string value in elixir should not change.

That’s where I’m worried

Sebb

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.

fsa

fsa

Hi again - I’m not on Windows, and have never seen or used conEmu, but there
seems to be a setting here : ConEmu | Settings › Environment page
that talks about utf8 … maybe play around with that?

If the file is utf8 encoded, and your display environment respects utf8, all the
toolchain between the dead file on disk and the display must respect utf8 - if
any of the pieces in your toolchain start to chop the content in the file up
according to different encoding you will be tripped up by surprise…

R.
Fridrik.

CharlesO

CharlesO OP

yes, I have Chcp utf-8 set

fsa

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 :slight_smile:

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)…!!! :stuck_out_tongue_winking_eye:

Be brave and explore… just remember to note down what works, and what not… and take backups… :slight_smile:

R.
Fridrik.

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews