mysql Incorrect string value: '\xE9 M.'
<p>I have a function "lr_encrypt" that use AES_ENCRYPT to encrypt the sensitive data in MySQL Table. </p>

<pre><code>drop function if exists lr_encrypt;
delimiter $$
create function lr_encrypt(p_text varchar(1000) character set utf8)
   returns varbinary(200)
begin

    declare l_word varchar(300) default '';
    declare l_key_length int default 512;

    select word
      into l_word  
      from lr_words;

    return aes_encrypt(p_text, SHA2(l_word,l_key_length));

end
$$
</code></pre>

<p>Now when I use this function I get the following error:</p>

<p>Error Code: 1366. Incorrect string value: '\xE9 M.' for column 'p_text' at row 8659</p>

<p>I checked the records 8659 and it keep the following value:</p>

<p><a href="https://i.stack.imgur.com/gBlK9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gBlK9.png" alt="enter image description here"></a></p>

<p>Please help fix above function !</p>