我有一个txt文件,如果我用标准文本编辑器打开记事本或scite,我可以读取这样的字符串:
Artist1 – Title 1
Artist2 – Title 2
Run Code Online (Sandbox Code Playgroud)
比我用我的PHP脚本打开它,我读了线:
$tracklistFile_name=time().rand(1, 1000).".".pathinfo($_FILES['tracklistFile']['name'], PATHINFO_EXTENSION);
if(((pathinfo($tracklistFile_name, PATHINFO_EXTENSION)=='txt')) && (move_uploaded_file($_FILES['tracklistFile']['tmp_name'], 'import/'.$tracklistFile_name))) {
$fileArray=file('import/'.$tracklistFile_name, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$fileArray=array_values(array_filter($fileArray, "trim"));
for($i=0; $i<sizeof($fileArray); $i++) {
echo $fileArray[$i]."<br />";
}
}
Run Code Online (Sandbox Code Playgroud)
和...哇...我得到这个结果:
Artist1 ? Title1
Artist2 ? Title2
Run Code Online (Sandbox Code Playgroud)
??? 这些符号是什么?我认为编码失败了.符号是错误的,我无法将它们插入数据库,也没有mysql_real_escape_string().事实上,当我尝试插入它时,我收到此错误:
Incorrect string value: '\x96 Titl...' for column 'atl' at row 1
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?建议?
编辑
尝试在插入/添加这些字符串之前添加utf8_encode():现在插入不会失败,但结果是:
Artist1 Title1
Artist2 Title2
Run Code Online (Sandbox Code Playgroud)
所以我丢失了信息.为什么?
假设我在网页中有一个带有 charset 的输入字段UTF8;假设我打开一个用 as 字符集编码的文本文件ISO-8859-1。
现在,我将带有特殊字符(例如,\xc3\xb4)的字符串从文件复制并粘贴到输入字段:我看到特殊字符正确显示到输入字段中。
ISO-8859-1谁进行从到 的转换UTF8?浏览器?
我有这个代码:
foreach (Object element in elements.under)
{
...
}
Run Code Online (Sandbox Code Playgroud)
而且我想在我进入最后一个周期时打印一些.我该怎么做?
我有这个 :
IEnumerable<int> intYear = Enumerable.Empty<int>();
Run Code Online (Sandbox Code Playgroud)
我该如何插入一些值?我没有看到任何intYear.Add()方法.
像2010年,2011年等......
代码:
news = (from New myNew in new News()
select myNew).Distinct().ToList();
Run Code Online (Sandbox Code Playgroud)
但是这个区别是具有相同值的"对象".myNew每个月我都需要在我的名单中.(一个用于一月,一个用于februaru,依此类推).比,news将获得12记录.
有可能是某种Distinct(myNew.Month)?
我有一个对象列表,如下所示:
ID:2000
Title:"Title 1"
Description:"My name is Marco"
ID:2000
Title:"Title 2"
Description:"My name is Luca"
ID:3000
Title:"Title 3"
Description:"My name is Paul"
ID:4000
Title:"Title 4"
Description:"My name is Anthony"
ID:4000
Title:"Title 5"
Description:"My name is Carl"
ID:4000
Title:"Title 6"
Description:"My name is Jadett"
Run Code Online (Sandbox Code Playgroud)
现在,我想用每个浏览(遍历)它.但我想从相同的ID开始遍历它.因此,首先是单个/唯一ID(2000,3000,4000,所以3个步骤)的foreach.对于每个"ID"步骤,每个标题/描述:对于ID 2000为2个步骤,对于ID 3000为1,对于ID 4000为3.列表按ID排序.
我该怎么做?通过...分组?呃... ...
我真的想用这个插件.但是,一旦我执行"导出为片段",我就看不到一个新标签,我可以在其中管理片段,设置Shourcut等等(如视频中所示).我只看到这个弹出窗口:
到底是怎么回事?添加新项目?
我已经更新到Visual Studio 2015的最后一个(更新3)版本,而我是Snippet Designer 1.6.2.
它应该删除类transition(因此CSS转换属性),将div移动到200px(立即),重新应用transitioncss属性,然后将div设置为动画(占用1秒)到右边.相反,它冻结了.
看起来应用css left属性需要更多的时间transition按类删除?还是addClass()异步?
var elem = $('#elem');
elem.removeClass('transition');
elem.css('left', 200);
elem.addClass('transition');
elem.css('left', 0);Run Code Online (Sandbox Code Playgroud)
#container {
position: relative;
width: 400px;
height: 200px;
background-color: red;
}
#elem {
width: 50px;
height: 50px;
position: relative;
left: 0;
top: 0;
background-color: blue;
}
.transition.linear.scritta {
-webkit-transition: all 1.0s linear;
-moz-transition: all 1.0s linear;
-ms-transition: all 1.0s linear;
-o-transition: all 1.0s linear;
transition: all 1.0s linear;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container">
<div id="elem" …Run Code Online (Sandbox Code Playgroud)我喜欢FP; 每次我想到它,我明白了解它:)
这是一个我不明白的例子.我总结8次相同的数字(0.1),我打印结果,总和和"原始":
std::cout.precision(100);
int numIteration = 8;
double step = 0.1;
double sum = 0.0;
for(int i = 0; i < numIteration; i++) {
sum += step;
}
std::cout << "orig stored as " << numIteration / 10.0 << std::endl;
std::cout << " sum stored as " << sum << std::endl;
Run Code Online (Sandbox Code Playgroud)
0.1存储为0.1000000000000000055511151231257827021181583404541015625,我希望在8和之后,它将被存储大于或等于0.8,存储为0.8000000000000000444089209850062616169452667236328125.
但结果震惊了我.实际上经过8次求和后,结果0.79999999999999993338661852249060757458209991455078125就越小.
另外,如果我检查两者的二进制输出,我可以看到总和比"原始"更"高":
0.8 stored as binary 0 01111111110 1001100110011001100110011001100110011001100110011001 // smaller
sum stored …Run Code Online (Sandbox Code Playgroud) 下面是我想要转换的代码:该double版本的VDT的帕德精通fast_ex()约(这里的老回购资源):
inline double fast_exp(double initial_x){
double x = initial_x;
double px=details::fpfloor(details::LOG2E * x +0.5);
const int32_t n = int32_t(px);
x -= px * 6.93145751953125E-1;
x -= px * 1.42860682030941723212E-6;
const double xx = x * x;
// px = x * P(x**2).
px = details::PX1exp;
px *= xx;
px += details::PX2exp;
px *= xx;
px += details::PX3exp;
px *= x;
// Evaluate Q(x**2).
double qx = details::QX1exp;
qx *= xx;
qx += details::QX2exp;
qx …Run Code Online (Sandbox Code Playgroud)