我需要在具有特殊字符的logic.js中进行查询。我已经完成了查询逻辑。
当我将特殊字符作为参数之一时出现我的问题。
当我把'がが',它找不到查询。当我把它的URL编码,我可以找到查询结果。如何在logic.js中编码我的特殊单词,以便查询我的单词?
这是我的代码
/**
* Track the trade of a commodity from one trader to another
* @param {org.stock.mynetwork.Receive} receive - the receive to be processed
* @transaction
*/
async function receiveCommodity(receive) {
let statement = 'SELECT org.stock.mynetwork.Commodity WHERE (owner == _$owner AND dataType == _$dataType)';
let qry = buildQuery(statement);
//this works
let allAssets = await query(qry, { owner: 'resource:org.stock.mynetwork.Trader#'+'%E3%81%8C%E3%81%8C', dataType: receive.dataType });
//this dont
let allAssets = await query(qry, { owner: 'resource:org.stock.mynetwork.Trader#'+'がが', dataType: receive.dataType });
}
我在搜索SO帖子的错误方面,解决方案很简单
我只需要encodeURI(yourVariable.toString())