Kiquenet
Kiquenet

Reputation: 15026

Encoding Spanish special characters in Page Title ASP.NET with UTF-8

I use a Title in my aspx page with special characters (á,é,í,ó,ú, etc).

Title="Información Económica"

Page.aspx

<%@ Page Language="C#" Title="Información Económica" MasterPageFile="~/MyMaster.Master" AutoEventWireup="true" CodeBehind="InformacionEconomica.aspx.cs" Inherits="Company.WebIU.InformacionEconomica" %>

web.config

<globalization culture="es-ES" uiCulture="es-ES" enableBestFitResponseEncoding="false" enableClientBasedCulture="false" fileEncoding="UTF-8" requestEncoding="UTF-8" responseEncoding="UTF-8" responseHeaderEncoding="UTF-8"/>

I have meta with charset="utf-8"

But the title is wrong:

<!DOCTYPE html>
<html lang="es">

<head>
<meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8" />

<title>
    Informaci?n Econ?mica
</title>

Works like using "acute"

Title="Informaci&oacute;n Econ&oacute;mica"

There are more 300 aspx pages, and I don't want replace all

á by &aacute;
é by &eacute;
í by &iacute;
ó by &oacute;
ú by &uacute;
etc...

Any suggestions?

Upvotes: 2

Views: 2886

Answers (2)

Afshar
Afshar

Reputation: 11533

Make sure that you are saving files with correct encoding. If your are using Visual Studio take a look at "File -> Advanced Save Options" and select a Unicode aware Encoding like Unicode (UTF-8 with signature).

Also make sure that your aspx/html file have following meta:

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

Finally check your page via different browser and see if anything changes.

Upvotes: 4

tomsv
tomsv

Reputation: 7277

Are your files saved as UTF-8? If not you need to convert them perhaps as suggested in this answer.

Then add the following (from MSDN - Select an Encoding for ASP.NET Web Page Globalization)

<configuration>
  <system.web>
    <globalization
      fileEncoding="utf-8"
      requestEncoding="utf-8"
      responseEncoding="utf-8"
      culture="en-US"
      uiCulture="es-ES"
    />
  </system.web>
</configuration>

Upvotes: 2

Related Questions