The safest way to include special characters is to use a character code. 
You are at the mercy of the browser otherwise and browsers behave very 
differently when confronted with unusual things.

You don't mention which browser you are using on Windows, which is a 
severe gap in the information you provided.

Here is an example which has been tested on Windows using IE, Firefox, 
Safari and Chrome (recent versions of all, I can't be bothered checking 
the versions). It also renders correctly if the file is opened in Word 
(versions based on xml).

require(hwriter)
pg <- openPage("specialcharacters.html")
hwrite("Test Special Characters", pg, heading = 1, br = TRUE)
hwrite("Ciencias Sociales y Jur&iacute;dicas n:74 | 33.94%", pg, br = TRUE)
hwrite("Ciencias Sociales y Jur&#237;dicas n:74 | 33.94%", pg, br = TRUE)
closePage(pg)

For other special character codes, see for example
http://www.ascii.cl/htmlcodes.htm

David Scott

On 31/07/2012 9:21 p.m., ramonovelar wrote:
> Thanks Arun,
> Yes, I have Windows 7. I have tried 2 versions of R, 2.14.1 and 2.15.x, but
> it did not change anything.
> Right now I can't try a different version of win.
>
> Ramón
>
> On Tuesday, July 31, 2012, arun kirshna [via R] wrote:
>
>> Hello,
>>
>> I tried your code in R 2.15 with Ubuntu 12.04.  It looks okay to me.
>>
>> datosdv<-"Ciencias Sociales y Jurídicas n:74 | 33.94%"
>>   print(datosdv)
>> #[1] "Ciencias Sociales y Jurídicas n:74 | 33.94%"
>>   library(hwriter)
>>   p=openPage('test.html')
>>   hwrite(datosdv,p,br=TRUE)
>>
>> #test.html output
>> Ciencias Sociales y Jurídicas n:74 | 33.94%
>>
>> Probably, it must be specific with the windows.  Are you using windows7?
>>
>>
>> A.K.
>>
>>
>>
>>
>> ----- Original Message -----
>> From: ramonovelar<[hidden 
>> email]<http://user/SendEmail.jtp?type=node&node=4638501&i=0>>
>>
>> To: [hidden email]<http://user/SendEmail.jtp?type=node&node=4638501&i=1>
>> Cc:
>> Sent: Monday, July 30, 2012 7:11 PM
>> Subject: [R] Accents and special character using hwriter (on Windows)
>>
>> Hello,
>>
>> I have a problem with special characters such as "í" or "ñ" when using
>> hwriter. This only happens when I use windows, it works fine on mac. If I
>> do:
>>
>> print(datosdv)
>> "Ciencias Sociales y Jurídicas n:74 | 33.94%"
>>
>> but:
>>
>> hwrite(datosdv, p, br=TRUE)
>> "Ciencias Sociales y Jur�dicas n:74 | 33.94%"
>>
>> The bad sign is in the code, is not a problem of the encoding of the html
>> page, that is in UTF-8.
>>
>> Does anybody have found this? Many thanks in advance.
>> Ramón
>>
>>
>>
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Accents-and-special-character-using-hwriter-on-Windows-tp4638474.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> [hidden email]<http://user/SendEmail.jtp?type=node&node=4638501&i=2>mailing 
>> list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>> ______________________________________________
>> [hidden email]<http://user/SendEmail.jtp?type=node&node=4638501&i=3>mailing 
>> list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>> ------------------------------
>>   If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://r.789695.n4.nabble.com/Accents-and-special-character-using-hwriter-on-Windows-tp4638474p4638501.html
>>   To unsubscribe from Accents and special character using hwriter (on
>> Windows), click 
>> here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4638474&code=cmFtb24ub3ZlbGFyQGdtYWlsLmNvbXw0NjM4NDc0fC0xNzk0Mjk1MDc3>
>> .
>> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
_________________________________________________________________
David Scott     Department of Statistics
                The University of Auckland, PB 92019
                Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to