Degree Symbol Display

Dear all,

I’m trying to display the degree symbol (the one used for temperature
or latitude/longitude coordinates).

I tried to use 167.chr , but the output on the website is ‘?’.

Code: degrees = [number_with_precision(degrees, precision=0),
167.chr, " ", number_with_precision(minutes, precision=0), "’ “,
number_with_precision(decimal_seconds, precision=2), '”’]

HTML Output: 37? 32’ 55.51"

Any ideas ?

Thanks,

I tried to use 167.chr , but the output on the website is ‘?’.

Again: °


Phlip

On 9/11/07, Nick [email protected] wrote:

Dear all,

I’m trying to display the degree symbol (the one used for temperature
or latitude/longitude coordinates).

I tried to use 167.chr , but the output on the website is ‘?’.

I don’t know where you got 167 from (perhaps you meant 176?). By
default, Rails output is UTF-8. The Unicode code point for the degree
sign is 0x00B0, which is the UTF-8 sequence:

“\xC2\xB0”

As mentioned, you can also use the HTML entity °

You mean alt code 167? In the code section, you can use it as HTML as your friends say.

2

If you are using Ruby < 2.0, then put this magic comment at the beginning of that file:

# coding: utf-8

If that does not work, then delete the file "file.txt" once, and try again. The file may not be compatible with the encoding.

In other ways, you can try these.

On PC: Hold down the Alt key, and on the numeric keypad on the right of the keyboard, type 0176 or Alt+ 248

On Mac: Press Option Shift 8.

Like this: °

Cheers,
Erick