Array.index with utf-8

M

Misha Ognev

Hi. I have a problem.

Windows7

I have an array with russian symbols. Then I want to find something
element in it by Array.index(elem).

In NetBeans 6.9.1 (it settings with utf-8) it works(write index in
FixNum class), but when i run .rb from a windows, it doesn't work(write
nil and NilClass). Why?

P.S. I'm paste the string: "# coding: utf-8" in the start of my script,
and all other operations works great, exclude this. What I must to do?

Thanks in advance
 
P

Peter Zotov

Hi. I have a problem.

Windows7

I have an array with russian symbols. Then I want to find something
element in it by Array.index(elem).

In NetBeans 6.9.1 (it settings with utf-8) it works(write index in
FixNum class), but when i run .rb from a windows, it doesn't
work(write
nil and NilClass). Why?

P.S. I'm paste the string: "# coding: utf-8" in the start of my
script,
and all other operations works great, exclude this. What I must to
do?

Thanks in advance

Are you sure that your file is really saved in UTF-8? Under Russian
Windows,
for example, the standard Notepad will save it either in CP1251, which
is the
ANSI locale, or in UTF-16. IIRC in WinXP notepad there is no way to
save text in
UTF-8 (I may be wrong through).
 
7

7stud --

Misha Ognev wrote in post #1000115:
Hi. I have a problem.

Post 5 lines or less of code that demonstrates the problem. Also, state
what version of ruby you are using.
 
M

Misha Ognev

Also, state what version of ruby you are using.
1.9.2
Post 5 lines or less of code that demonstrates the problem.

pos = d.index(@buttonarray.get_value)+1

I have a big system with a diary, IO, wxRuby et.c. I can't send you code
you understand in 5 strokes.
Are you sure that your file is really saved in UTF-8? Under Russian
Windows, for example, the standard Notepad will save it either in
CP1251...
File in UTF-8, all works with it fine. Only index function is worng
 
B

Brian Candler

Misha Ognev wrote in post #1000176:
Post 5 lines or less of code that demonstrates the problem.

pos = d.index(@buttonarray.get_value)+1


STDERR.puts "d.encoding=#{d.encoding}"
STDERR.puts "value.encoding=#{@buttonarray.get_value.encoding}"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top