# Cyrillic symbols in comments

**URL:** <https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693>\
**Category:** General Usage\
**Tags:** comment\
**Created:** [November 6, 2020, 5:42pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693 "2020-11-06T17:42:26Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 5:42pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/1 "2020-11-06T17:42:26Z")

</div>

When I use comments, typed in Cyrillic in a file (“hello.jl”) and load this file like that include(“hello.jl”), I have the error message: ERROR: LoadError: syntax: invalid UTF-8 syntax

Example:

println(“Hello !”) # Булгъар

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 6, 2020, 5:52pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/2 "2020-11-06T17:52:30Z")

</div>

> [@gvbelov](#):
>
> println(“Hello !”) # Булгъар

It appares that the quotation marks you use are the problem, not the comments:

```julia
julia> println(“Hello !”) # Булгъар
ERROR: syntax: invalid character "“" near column 9
Stacktrace:
 [1] top-level scope at none:1

julia> println("Hello !") # Булгъар
Hello !

```

Use ASCII quotation marks.

---

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 5:54pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/3 "2020-11-06T17:54:20Z")

</div>

Same file, but with comment works fine

println(“Hello !”) # some comment

---

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 5:55pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/4 "2020-11-06T17:55:17Z")

</div>

In REPL Cyrillic comments works too

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 6, 2020, 6:18pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/5 "2020-11-06T18:18:55Z")

</div>

> [@gvbelov](#):
>
> LoadError: syntax: invalid UTF-8 syntax

Probably you didn’t save the file in the UTF-8 encoding, but used some other encoding like UTF-16. What editor are you using?

An example in the REPL of invalid UTF-8 data can be generated by creating a string from random bytes:

```julia
julia> Meta.parse("# " * String(rand(UInt8, 10)))
ERROR: Base.Meta.ParseError("invalid UTF-8 sequence")

```

---

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 6:37pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/6 "2020-11-06T18:37:30Z")

</div>

It does not depend on the editor, I have used several Notepad++, TED Notepad,… For example, file with such comments works

println(“Hello !”) # Հայերեն

println(“Hello !”) # სომეხური ნინა

println(“Hello !”) # میلیون نفر بۇ دیلده

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 6, 2020, 6:45pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/7 "2020-11-06T18:45:37Z")

</div>

> [@gvbelov](#):
>
> It does not depend on the editor, I have used several Notepad++, TED Notepad,… For example, file with such comments works

Any decent editor will preserve the encoding of the file by default, so simply opening it and re-saving in another editor will not fix the encoding. You’ll have to change an editor setting somewhere to specify conversion to UTF-8. How to do this will vary with the editor.

For example, for [Notepad++ see here](https://stackoverflow.com/questions/7256049/how-do-i-convert-an-ansi-encoded-file-to-utf-8-with-notepad). For TED Notepad there is an [encoding option in the File menu](http://jsimlo.sk/notepad/manual/wiki/index.php/File_menu#Encoding). And so forth.

PS. I would strongly recommend using a modern programming editor like [vsCode](https://www.julia-vscode.org/). (To change the encoding to UTF-8 in vsCode, there is a [menu at the bottom of the file window](https://stackoverflow.com/questions/30082741/change-the-encoding-of-a-file-in-visual-studio-code#:~:text=In%20the%20bottom%20bar%20of,Click%20Save%20with%20encoding%20.).)

---

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 6:56pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/8 "2020-11-06T18:56:55Z")

</div>

Well. But why this line is Ok

println(“Hello !”) # Հայերեն

and this is not

println(“Hello !”) # Булгъар

?  
And what does the editor have to do with it?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 6, 2020, 6:57pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/9 "2020-11-06T18:57:45Z")

</div>

> [@gvbelov](#):
>
> Well. But why this line is Ok

It depends on how it is encoded in whatever encoding you are using and whether that happens to correspond to a valid UTF-8 sequence.

> [@gvbelov](#):
>
> And what does the editor have to do with it?

The editor determines what the default encoding is and how to change it, as I explained in my message [above](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/7).

---

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 7:02pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/10 "2020-11-06T19:02:04Z")

</div>

Well. Did you try to make file with the text

println(“Hello !”) # Булгъар

using and run it in REPL?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 6, 2020, 7:36pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/11 "2020-11-06T19:36:31Z")

</div>

> [@gvbelov](#):
>
> Well. Did you try to make file with the text
> 
> `println(“Hello !”) # Булгъар`
> 
> using and run it in REPL?

Yes. It works fine (both via `julia foo.jl` and by `include("foo.jl")` in the REPL), saved in UTF-8 encoding in a file `foo.jl`, once you [correct the quotes to straight quotes](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/2):

```julia
println("Hello !") # Булгъар

```

(Use a programming editor like vsCode! Non-programming editors will sometimes “smart-correct” quotes `"..."` into curly quotes `“...”`, which is not what you want for programming. Or maybe your browser is doing that to your discourse posts?)

---

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 8:13pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/12 "2020-11-06T20:13:42Z")

</div>

Thank you very much!  
(I use the right quotes, probably they are converted in this window).  
Yet I do not understand the idea. It is COMMENT, it is for me, not for compiler/interpreter. One can use here any symbols.  
I thought, the compiler just skip the text after the symbol #.

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [November 6, 2020, 8:22pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/13 "2020-11-06T20:22:26Z")

</div>

It has to parse text after `#` in order to find newline symbol.

---

<div class="post-metadata">

**Author:** ![gvbelov](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gvbelov](https://discourse.julialang.org/u/gvbelov)\
**Post date:** [November 6, 2020, 8:27pm UTC](https://discourse.julialang.org/t/cyrillic-symbols-in-comments/49693/14 "2020-11-06T20:27:30Z")

</div>

Thank you! I finally figured it out!
