[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Searching for latin/umlaut characters in string

John Butler

5/1/2008 8:46:00 PM

Hi,

Ive read up a bit about uicode strings and the issues with rails after i
tried to save some data which contained an umlaut character. I got the
following error below when searching for a name that contained the
character é.

Unclosed quotation mark after the character string ')

Is there anyway to search a string for these types of characters and
then ill decide what to do later??

Some sort of string method like scan or include??

JB
--
Posted via http://www.ruby-....

7 Answers

Xavier Noria

5/1/2008 8:56:00 PM

0

T24gVGh1LCBNYXkgMSwgMjAwOCBhdCAxMDo0NSBQTSwgSm9obiBCdXRsZXIgPGpvaG5ueWJ1dGxl
cjdAZ21haWwuY29tPiB3cm90ZToKCj4gIEl2ZSByZWFkIHVwIGEgYml0IGFib3V0IHVpY29kZSBz
dHJpbmdzIGFuZCB0aGUgaXNzdWVzIHdpdGggcmFpbHMgYWZ0ZXIgaQo+ICB0cmllZCB0byBzYXZl
IHNvbWUgZGF0YSB3aGljaCBjb250YWluZWQgYW4gdW1sYXV0IGNoYXJhY3Rlci4gIEkgZ290IHRo
ZQo+ICBmb2xsb3dpbmcgZXJyb3IgYmVsb3cgd2hlbiBzZWFyY2hpbmcgZm9yIGEgbmFtZSB0aGF0
IGNvbnRhaW5lZCB0aGUKPiAgY2hhcmFjdGVyIMOpLgo+Cj4gIFVuY2xvc2VkIHF1b3RhdGlvbiBt
YXJrIGFmdGVyIHRoZSBjaGFyYWN0ZXIgc3RyaW5nICcpCgpTb3VuZHMgbGlrZSBhbiBlbmNvZGlu
ZyBpc3N1ZSB3aXRoIHRoZSBzb3VyY2UgY29kZSBpdHNlbGYuIEFyZSB5b3UKd3JpdGluZyB0aGF0
ICLDqSIgaW4gdGhlIHByb2dyYW0/IElmIHllcywgaXMgeW91ciBlZGl0b3IgY29uZmlndXJlZCB0
bwp3cml0ZSBVVEY4Pwo=

John Butler

5/2/2008 8:18:00 AM

0

Xavier Noria wrote:
> On Thu, May 1, 2008 at 10:45 PM, John Butler <johnnybutler7@gmail.com>
> wrote:
>
>> Ive read up a bit about uicode strings and the issues with rails after i
>> tried to save some data which contained an umlaut character. I got the
>> following error below when searching for a name that contained the
>> character é.
>>
>> Unclosed quotation mark after the character string ')
>
> Sounds like an encoding issue with the source code itself. Are you
> writing that "é" in the program? If yes, is your editor configured to
> write UTF8?

No the string is coming in via a csv file.

--
Posted via http://www.ruby-....

7stud --

5/2/2008 9:20:00 AM

0

John Butler wrote:
> Xavier Noria wrote:
>> On Thu, May 1, 2008 at 10:45 PM, John Butler <johnnybutler7@gmail.com>
>> wrote:
>>
>>> Ive read up a bit about uicode strings and the issues with rails after i
>>> tried to save some data which contained an umlaut character. I got the
>>> following error below when searching for a name that contained the
>>> character é.
>>>
>>> Unclosed quotation mark after the character string ')
>>
>> Sounds like an encoding issue with the source code itself. Are you
>> writing that "é" in the program? If yes, is your editor configured to
>> write UTF8?
>
> No the string is coming in via a csv file.


str = "My cafe\xcc\x81 is good."
puts str

if str.include?("cafe\xcc\x81")
puts "yes"
else
puts "no"
end
--
Posted via http://www.ruby-....

Xavier Noria

5/2/2008 9:52:00 AM

0

T24gRnJpLCBNYXkgMiwgMjAwOCBhdCAxMDoxNyBBTSwgSm9obiBCdXRsZXIgPGpvaG5ueWJ1dGxl
cjdAZ21haWwuY29tPiB3cm90ZToKCj4gWGF2aWVyIE5vcmlhIHdyb3RlOgo+Cj4gID4gU291bmRz
IGxpa2UgYW4gZW5jb2RpbmcgaXNzdWUgd2l0aCB0aGUgc291cmNlIGNvZGUgaXRzZWxmLiBBcmUg
eW91Cj4gID4gd3JpdGluZyB0aGF0ICLDqSIgaW4gdGhlIHByb2dyYW0/IElmIHllcywgaXMgeW91
ciBlZGl0b3IgY29uZmlndXJlZCB0bwo+ICA+IHdyaXRlIFVURjg/Cj4KPiAgTm8gdGhlIHN0cmlu
ZyBpcyBjb21pbmcgaW4gdmlhIGEgY3N2IGZpbGUuCgpJcyB0aGUgQ1NWIGZpbGUgaW4gVVRGOD8K

John Butler

5/2/2008 12:52:00 PM

0

Xavier Noria wrote:
> On Fri, May 2, 2008 at 10:17 AM, John Butler <johnnybutler7@gmail.com>
> wrote:
>
>> Xavier Noria wrote:
>>
>> > Sounds like an encoding issue with the source code itself. Are you
>> > writing that "é" in the program? If yes, is your editor configured to
>> > write UTF8?
>>
>> No the string is coming in via a csv file.
>
> Is the CSV file in UTF8?

Its Ansii as far as i can tell. Its actually coming from an excel
spread sheet and the user then "saves as" comma separted csv. Then its
import to the application wher i am running into the problem.
--
Posted via http://www.ruby-....

Xavier Noria

5/2/2008 1:22:00 PM

0

T24gRnJpLCBNYXkgMiwgMjAwOCBhdCAyOjUyIFBNLCBKb2huIEJ1dGxlciA8am9obm55YnV0bGVy
N0BnbWFpbC5jb20+IHdyb3RlOgo+Cj4gWGF2aWVyIE5vcmlhIHdyb3RlOgo+ICA+IE9uIEZyaSwg
TWF5IDIsIDIwMDggYXQgMTA6MTcgQU0sIEpvaG4gQnV0bGVyIDxqb2hubnlidXRsZXI3QGdtYWls
LmNvbT4KPiAgPiB3cm90ZToKPiAgPgo+ICA+PiBYYXZpZXIgTm9yaWEgd3JvdGU6Cj4gID4+Cj4g
ID4+ICA+IFNvdW5kcyBsaWtlIGFuIGVuY29kaW5nIGlzc3VlIHdpdGggdGhlIHNvdXJjZSBjb2Rl
IGl0c2VsZi4gQXJlIHlvdQo+ICA+PiAgPiB3cml0aW5nIHRoYXQgIsOpIiBpbiB0aGUgcHJvZ3Jh
bT8gSWYgeWVzLCBpcyB5b3VyIGVkaXRvciBjb25maWd1cmVkIHRvCj4gID4+ICA+IHdyaXRlIFVU
Rjg/Cj4gID4+Cj4gID4+ICBObyB0aGUgc3RyaW5nIGlzIGNvbWluZyBpbiB2aWEgYSBjc3YgZmls
ZS4KPiAgPgo+ICA+IElzIHRoZSBDU1YgZmlsZSBpbiBVVEY4Pwo+Cj4gIEl0cyBBbnNpaSBhcyBm
YXIgYXMgaSBjYW4gdGVsbC4gIEl0cyBhY3R1YWxseSBjb21pbmcgZnJvbSBhbiBleGNlbAo+ICBz
cHJlYWQgc2hlZXQgYW5kIHRoZSB1c2VyIHRoZW4gInNhdmVzIGFzIiBjb21tYSBzZXBhcnRlZCBj
c3YuICBUaGVuIGl0cwo+ICBpbXBvcnQgdG8gdGhlIGFwcGxpY2F0aW9uIHdoZXIgaSBhbSBydW5u
aW5nIGludG8gdGhlIHByb2JsZW0uCgpJZiB0aGUgQ1NWIGlzIEFOU0lJLCBhbmQgdGhlIFJ1Ynkg
c291cmNlIGNvZGUgaXMgQU5TSUksIHdoZXJlIGlzIHRoZQoiw6kiIGNvbWluZyBmcm9tPyA6LSkK

John Butler

5/2/2008 2:38:00 PM

0

Xavier Noria wrote:
> On Fri, May 2, 2008 at 2:52 PM, John Butler <johnnybutler7@gmail.com>
> wrote:
>> >>
>> >> No the string is coming in via a csv file.
>> >
>> > Is the CSV file in UTF8?
>>
>> Its Ansii as far as i can tell. Its actually coming from an excel
>> spread sheet and the user then "saves as" comma separted csv. Then its
>> import to the application wher i am running into the problem.
>
> If the CSV is ANSII, and the Ruby source code is ANSII, where is the
> "é" coming from? :-)

Here is an example of the csv file with the word below and how it is
displayed. They are identical. It looks like the file is utf-8 after
all.

Müller




Attachments:
http://www.ruby-...attachment/1836/t...

--
Posted via http://www.ruby-....