2016-12-22 22 views
1

我有问题,在我的数据表中äöü等显示为 。我如何在自举数据表中将transform转换为ö?

奇怪的是:我的网站上的其他地方的“变音符号”显示正确。如您所见,我正在使用德语语言属性,并且Einträge显示正确。所以问题只发生在我的表内。

另一件事:在我的本地主机上,一切都显示正常,还表。它只发生在我的服务器上。下面一个例子,我看到它在我的网站:

$('.data-table').DataTable({ 
 
    "language": { 
 
      "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json", 
 
     }, 
 
    "scrollX": true, 
 
    
 
});
div.dataTables_wrapper { 
 
    width: 100%; 
 
    margin: 0 auto; 
 
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
<link rel="stylesheet" href="https://almsaeedstudio.com/themes/AdminLTE/plugins/datatables/dataTables.bootstrap.css"> 
 

 
<script src="https://almsaeedstudio.com/themes/AdminLTE/plugins/jQuery/jquery-2.2.3.min.js"></script> 
 
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script> 
 
<script src="https://almsaeedstudio.com/themes/AdminLTE/plugins/datatables/dataTables.bootstrap.min.js"></script> 
 
<table class="data-table table table-bordered table-striped"> 
 
    <thead> 
 
    <tr> 
 
     <th>Name</th> 
 
     <th>Position</th> 
 
     <th>Location</th> 
 
     <th>Age</th> 
 
     <th>Start date</th> 
 
     <th>Salary</th>  
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
    <tr> 
 
     <td>Sm�rebr�d</td> 
 
     <td>System Architect</td> 
 
     <td>Edinburgh</td> 
 
     <td>Mal�r</td> 
 
     <td>2011/04/25</td> 
 
     <td>$320,800</td> 
 
    </tr> 
 
     <tr> 
 
     <td>Tiger Nixon</td> 
 
     <td>System Architect</td> 
 
     <td>Edinburgh</td> 
 
     <td>Mal�r</td> 
 
     <td>2011/04/25</td> 
 
     <td>$320,800</td> 
 
    </tr> 
 
    
 
    
 
    </tbody> 
 
</table>

+1

@madalinivascu是的,我已经有了。我的编辑器(TextWrangler)的编码为“Unicode UTF-8”,在我的头文件中也使用了' – Jarla

回答

2

如果您正在从数据库中获取数据,您可以尝试在选择数据库后立即添加以下2行吗?我希望能解决你的问题。

mysql_query("SET NAMES 'utf8'"); 
mysql_query("SET CHARACTER SET 'utf8'"); 
+0

我在我的代码中测试了这个'$ db = new PDO(“mysql:host =”。DBHOST。“; port = 8889; dbname =”。DBNAME,DBUSER,DBPASS); \t $ db-> setAttribute(PDO :: ATTR_ERRMODE,PDO :: ERRMODE_EXCEPTION); mysql_query(“SET NAMES'utf8'”); mysql_query(“SET CHARACTER SET'utf8'”);'不幸的是没有变化 – Jarla

+0

我这样写的:'$ db - > exec(“set names utf8”);'并且工作! – Jarla

+1

恭喜!快乐的编码! :) –

相关问题