Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > same character show different code in two machine

Reply
Thread Tools

same character show different code in two machine

 
 
Ryan Smith
Guest
Posts: n/a
 
      02-07-2010
one chinese character show different code in two different machine.

machine A: \243\244
machine B: \302\245

so I have to using different pattern for two machines, like this:
machine A: text.split("\243\244")
machine B: text.split("\302\245")

I know this is not the proper way, but could some one tell me:
what is the root course?
What different between machine A and B?
what is the proper way to handle this ?

thanks very much!

-ryan
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Ryan Smith
Guest
Posts: n/a
 
      02-08-2010
Thanks, Walton,

need include something?

irb(main):006:0> "Hello".encoding
NoMethodError: undefined method `encoding' for "Hello":String
from (irb):6
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      02-08-2010
Ryan Smith wrote:
> one chinese character show different code in two different machine.
>
> machine A: \243\244
> machine B: \302\245


In hex those are: \xa3\xa4
\xc2\xa5

The first is not valid UTF-8. I suppose it might be UTF-16: U+A3A4 or
U+A4A3 depending on little or big-endian. Or it could be some older
proprietary Asian encoding.

The second of these could be UTF-8. If so it would be codepoint 165, the
'yen' symbol. Or it could be U+C2A5 in UTF-16.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Marnen Laibow-Koser
Guest
Posts: n/a
 
      02-08-2010
Ryan Smith wrote:
> Thanks, Walton,
>
> need include something?
>
> irb(main):006:0> "Hello".encoding
> NoMethodError: undefined method `encoding' for "Hello":String
> from (irb):6


No, I don't think that method exists in 1.8.

Best,
--Â*
Marnen Laibow-Koser
http://www.marnen.org

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

 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      02-08-2010
Ryan Smith wrote:
>> The first is not valid UTF-8. I suppose it might be UTF-16: U+A3A4 or
>> U+A4A3 depending on little or big-endian. Or it could be some older
>> proprietary Asian encoding.

>
> [Ryan] How to correct this (to UTF-, it is a English XP Pro with PRC
> as system locale.


Sorry, I have no idea. Are you sure that \xa3\xa4 correponds exactly to
that one character? Is the rest of the encoding variable length or fixed
length? (e.g. are all characters two bytes long, even a western letter
"A"?)

Questions about Microsoft operating systems and what encodings they use
really belong in a Microsoft users' forum, as it's not anything to do
with Ruby.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Ryan Smith
Guest
Posts: n/a
 
      02-08-2010
Brian Candler wrote:
> Ryan Smith wrote:
>>> The first is not valid UTF-8. I suppose it might be UTF-16: U+A3A4 or
>>> U+A4A3 depending on little or big-endian. Or it could be some older
>>> proprietary Asian encoding.

>>
>> [Ryan] How to correct this (to UTF-, it is a English XP Pro with PRC
>> as system locale.

>
> Sorry, I have no idea. Are you sure that \xa3\xa4 correponds exactly to
> that one character? Is the rest of the encoding variable length or fixed
> length? (e.g. are all characters two bytes long, even a western letter
> "A"?)
>
> Questions about Microsoft operating systems and what encodings they use
> really belong in a Microsoft users' forum, as it's not anything to do
> with Ruby.



I have no idea either, but I will upgrade to ruby 1.9 to leverage
string.encoding feature. thank you.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it correct? Two same named classes in different unnamed namespaceget same typeid Qi C++ 7 08-07-2011 09:18 PM
Weird issue, same code, same browser, two different apache servers,very different css bluebaron HTML 3 11-04-2009 07:13 PM
running same script on same data on two different machines -->different result Christopher Brewster Python 5 11-14-2008 08:19 PM
Any ideas on different file sizes showing of the same file on two different systems? Joe Computer Support 4 01-10-2005 01:05 AM
same code produces different decimal symbol on different computers with same settings ASP General 2 12-29-2003 02:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57