4

I am frequently working with template files in Netbeans 7.2: In TYPO3, with HTML-based and Fluid templates; in OXID eSales, with Smarty templates.

If a template file contains a charset variable like follows, Netbeans utters a warning each time I open or save the file.
<meta http-equiv="Content-Type" content="text/html; charset=[{$oView->getCharSet()}]">

The warning:

The encoding [{$oView->getCharSet()}] specified in meta tag of the 
document base.tpl is invalid. Do you want to load the file using 
UTF-8 encoding?
                                                            [Yes] [No]

How can I turn this off?
(As a workaround, I usually replace [{$oView->getCharSet()}] with utf-8. But it's ugly.)

Mateng
  • 3,742
  • 5
  • 37
  • 64

2 Answers2

1

HTML validation warnings can be configured to some extent using Netbeans hints. I haven't been able to verify this (as I don't have the latest version) but perhaps you can check the latest build if you IDE version doesn't provide an option to turn the warning off.

Go to Tools -> Options -> Editor -> Hints -> HTML Validator

Build 7.1 onwards a new category called Encoding issues have been added to Netbeans. I think you would probably find an option to enable/disable the hint that controls this HTML encoding warning.

References:
Wrong Encoding Warning on HTML-Files
Not the exact bug you're facing but it makes references to related validation hints:

There are some new hints options for HTML language in the editor options. There are three new subcategories of Html Validator category - Encoding issues, Tags matching issues and Others.

HTML Hints in Netbeans

Ravi K Thapliyal
  • 51,095
  • 9
  • 76
  • 89
  • Thanks Ravi. I disabled *all* warnings in the _HTML Validator_ tree. However, the error message persists (NB 7.2). I will file this over at netbeans.org, too. Maybe we have more luck with 7.3. – Mateng May 02 '13 at 09:10
  • @Mateng Yes, with the use of templates becoming so commonplace now (I have some experience with FreeMarker and Velocity) it's high time they take it on priority. Please, do post your updates here! – Ravi K Thapliyal May 02 '13 at 16:59
0

I tried this on both 7.1 and 7.0.1 and got the same results. It seems that changing charset encoding does not work until NetBeans is restarted.

1. Start NetBeans
2. Create a project by default
It means project encoding is set to "UTF-8" by default

3. Create a HTML file from File>New File... and Other>HTML File
The project encoding is set to UTF-8, so created file also should be UTF-8
encoding. -> OK


<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
    <div>TODO write content</div>
</body>
</html>
  1. Modify "UTF-8" to "Shift_JIS" or other encoding like

    <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
    
    <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
    

    Yellow line is displayed on the line and it complains

    Warning Internal encoding declaration "euc-jp" disagrees with the actual encoding of the document ("utf-8"). From line 9, column 9; to line 9, column 76 (Rule Category: All Other) newhtml.html
    /home/mkatakai/NetBeansProjects/WebApplication7/web/newhtml.html:9

  2. Open propery of the file, it still says "UTF-8" (screenshot)

  3. close the file and open it again, the warning is still displayed, project dialog of the file is still saying it's UTF-8
  4. close the project and open it again, however, the warning is still displayed, project dialog of the file is still saying it's UTF-8
  5. quit NetBeans and start it again, finally the warning disapper and project dialog says it's EUC-JP (screenshot)
SeasonalShot
  • 2,357
  • 3
  • 31
  • 49
  • Please, give the original author some credit by adding a reference. Don't just copy-paste. Original post at https://netbeans.org/bugzilla/show_bug.cgi?id=206559 by `Masaki Katakai`. – Ravi K Thapliyal May 01 '13 at 15:27
  • 1
    You've misunderstood `Mateng`'s problem. What you've suggested automatically **changes** the file encoding to the one declared in content-type (EUC-JP in your case) but he wants to keep a template expression `$oView->getCharSet()` as its value which obviously won't work as it's not a valid encoding. – Ravi K Thapliyal May 01 '13 at 16:14