Unicode Characters not allowed in the include function

I created the a QR.jl file as following:

using LinearAlgebra, Random, Statistics, SpecialFunctions, BenchmarkTools, LoopVectorization, Distributions

function QuantileLoss(r::Vector{T}, τ::T, h::T) where T <: AbstractFloat
  l = zero(T)
  @turbo for i in eachindex(r)
    abs_ri = abs(r[i])
    l += 0.5*((abs_ri>h)*abs_ri+ (abs_ri<=h)*(h/2+r[i]^2/(2*h)))+(τ-0.5)*r[i]
  end
  l/length(r)
end

However, if I run include(“QR.jl”) in REPL, it returns a parsing error due to the unicode characters (τ in this case) . Is it just not possible to have unicode characters in include?
图片

1 Like

Unicode characters should be fine. Are you sure that’s the error?
The issue looks like it’s the parentheses. (abs_ri<=h)(h/2+r[i]^2/(2*h))) is not allowed. If you want those to be multiplied you need a * there. Same with (abs_ri>h)abs_ri probably.

Also, when posting here, be sure to put your code in a code block with ``` before and after the code.

# it makes code look like this
function foo()
    # blah blah
    return nothing
end
1 Like

I have fixed the code block. There are in fact * signs in place.

1 Like

Julia handles Unicode fine, what you’ve got here could be an issue with Unicode encodings. There are multiple possible text encodings, including just for Unicode, and it seems Julia is expecting utf8, while you’re providing it with text encoded in some other format.

2 Likes