I am using servlet with mysql connector 5.1.44 to connect to mysql database.
componentRef.onDestroy(_ => {
subscriptions.forEach(x => x.unsubscribe());
componentRef.changeDetectorRef.detach();
});
this works well for multilanguage input but when trying to save emojis, it ends up saving only "??". what can I do to save emoji using just servlet?
servlet code
<?php
$i = 0;
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;" ><input type="text" name="name[<?php echo $i; ?>]" value="<?php echo $item["name"]; ?>"></td>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;"><input type="text" name="code[<?php echo $i; ?>]" value="<?php echo $item["code"]; ?>"></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><input type="text" name="quantity[<?php echo $i; ?>]" value="<?php echo $item["quantity"]; ?>"></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><input type="text" name="price[<?php echo $i; ?>]" value="<?php echo $item["price"]; ?>"></td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><a href="index.php?action=remove&code=<?php echo $item["code"]; ?>" class="btnRemoveAction">Remove Item</a></td>
</tr>
<?php
$item_total += ($item["price"]*$item["quantity"]);
$i++;
}
?>
答案 0 :(得分:0)
有问题的表/数据库是否设置为存储这些unicode值?您在连接字符串中设置的字符集仅控制数据在客户端和服务器之间的传输方式。如果该列无法存储该数据,则最终会导致数据损坏。