首页 \ 问答 \ 编码:使用'utf8' - 问题(Encoding: use 'utf8' - quesiton)

编码:使用'utf8' - 问题(Encoding: use 'utf8' - quesiton)

当我use encoding 'utf8'时,我可以省略use 'utf8' pragma吗?

#!/usr/bin/env perl
use warnings;
use 5.012;
use Encode qw(is_utf8);

use encoding 'utf8';


my %hash = ( '☺' => "☺", '\x{263a}' => "\x{263a}", 'ä' => "ä", 'a' => "a" );
for my $key ( sort keys %hash ) {
    say "UTF8 flag is turned on in the STRING $key" if is_utf8( $hash{$key} );
    say "UTF8 flag is NOT turned on in the STRING $key" if not is_utf8( $hash{$key} );
}

Can I omit the use 'utf8'-pragma when I am already using use encoding 'utf8'?

#!/usr/bin/env perl
use warnings;
use 5.012;
use Encode qw(is_utf8);

use encoding 'utf8';


my %hash = ( '☺' => "☺", '\x{263a}' => "\x{263a}", 'ä' => "ä", 'a' => "a" );
for my $key ( sort keys %hash ) {
    say "UTF8 flag is turned on in the STRING $key" if is_utf8( $hash{$key} );
    say "UTF8 flag is NOT turned on in the STRING $key" if not is_utf8( $hash{$key} );
}

原文:https://stackoverflow.com/questions/5244719
更新时间:2024-03-04 07:03

最满意答案

您应该循环数组并搜索特定name

var energy = '';

$.each(food0.nutrient, function () {
    if (this.name == 'Energy') {
        energy = this.value;

        return false; // == break; return true == continue;
    }
});

You should loop your array and search for specific name:

var energy = '';

$.each(food0.nutrient, function () {
    if (this.name == 'Energy') {
        energy = this.value;

        return false; // == break; return true == continue;
    }
});

相关问答

更多
  • 不幸的是,没有办法将mLab Data API与Ajax一起使用并保持API密钥安全。 我们建议您在您的mLab数据库之上实施您自己的RESTful API服务器,该数据库可充当数据库的网守。 您的客户端应用程序将向API服务器发出Ajax请求。 虽然本教程使用Angular而不是Ajax,但下面是我描述的体系结构的一个很好的示例: https : //devcenter.heroku.com/articles/mean-apps-restful-api 。 Unfortunately there is n ...
  • 如果你想要一个通用的代码,我建议你将代码和配置数据分离成2个文件。 这样,您可以管理配置数据(要检索的URL,JSON属性),而无需修改实际的Python代码。 这通常被认为是一种很好的做法,但它意味着管理两个文件而不是一个文件,因此如果你在一个非常小的项目上,这可能会有点负担。 在您的情况下,您可以: conf.ini bitcoin_api.py conf.ini 配置文件如下所示: [COINDESK] url: https://api.coindesk.com/v1/bpi/currentprice ...
  • 这是等价的。 它在javascript中有点漂亮。 服务器端代码: var result = HTTP.post("https://api.locu.com/v2/venue/search", { data: { "fields": ["name", "menu_items", "location", "categories", "description"], "menu_item_queries": [{ "price": { ...
  • 我可以在你的Github repo上看到,你的结构化模型就像关系数据库(注意:你用关系数据库在你的问题中命名为'SQL数据库')与规范化的数据模型 : 例如:在Topic.js中,您可以通过引用来引用帖子: posts: [ { type: mongoose.Schema.Types.ObjectId, ref: 'Post', }, ], 它当然可以像它一样工作,但是使用NoSQL和特别是MongoDB,您可以将文档嵌入到另一个文档中。 为什么不直接将Post ...
  • 根据建议,我最终创建了单独的应用程序,以保持代码中的干净结构。 According to advises i ended up creating separate apps to keep clean structure in the code.
  • 感谢@bdougie,我仔细查看了服务器的控制台日志,发现了2个问题: 1)表单是发送对象,而不是命名对象,所以只需要使用req.body作为我的newItem变量 2)来自session的userId在添加到newItem时给出了错误 - 老实说,我只是将它移动到创建日期之下并使用console.log进行测试,现在它正在运行。 Thanks to @bdougie, I looked carefully at my console log from the server and found 2 issu ...
  • 它可以是从简单的东西到更复杂的东西,你如何编写它取决于你,假设你是唯一一个将使用API的人,据我所知,没有标准设置在石头上对于这种事情,但解决这类问题的一个好方法是创建一个方便的功能,无论是客户端还是服务器端,比如像 function fetch(what, data) { data.what = what; return $.ajax({ url : '/my/ajaxapi.php', data : data, data ...
  • 我认为你应该看看RESTful API的含义。 对于错误,您可以使用HTTP状态。 如果状态为200,则一切正常。 你可以在这里阅读http://www.infoq.com/articles/designing-restful-http-apps-roth I think you should look at RESTful APIs implimentations. For errors you can use HTTP status. If status is 200 than everything i ...
  • 您应该循环数组并搜索特定name : var energy = ''; $.each(food0.nutrient, function () { if (this.name == 'Energy') { energy = this.value; return false; // == break; return true == continue; } }); You should loop your array and search for specif ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。