How to properly block userAgent? like\ xA3\ xA9\ x09 by nginx

userAgent is as follows:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4 ) AppleWebKit/537.36\ (KHTML,  like Gecko ) \x09\x09\x09Chrome/55.0.2883.95   

Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html\xA3\xA9

try to block in nginx, the code is as follows:

if ($http_user_agent ~ "Mozilla/5.0\ \(compatible;\ Baiduspider/2.0;\ +http://www.baidu.com/search/spider.html\\\xA3\\\xA9") { 
    return 403; 
}

found no effect, how to block this kind of userAgent, or how to deal with characters like xA3xA9 x09? Thank you


this is the UserAgent of Baidu Spider, if you want the site not to be crawled.
you can configure robots.txt to reject all fetching so that these requests don't come and naturally don't have to be processed.

Menu