Hello, I just want to write some few simple lines to a text file in C++, but I want them to be encoded in UTF-8. What is the easiest and simple way to do so?
Thanks
Hi,
I've inherited a project which we are trying to migrate to MySQL 5 from MySQL 4.0(!) and from myISAM to InnoDB. Queries are now falling down because they are being constructed using an ADODB connection's -qstr() on all parameters, including ints. Where no value is provided I end up with:
INSERT INTO tablename VALUES ('', 'stuff'...)
where the first column is an auto_increment. This causes an error (fair enough since '' isn't an int). Is there a switch in MySQL to make it behave as it used to (I assume it just silently converted to 0?)
Thanks.
I see extra characters like â showing because of encoding issues as I found out here -
HTML encoding issues - "Â" character showing up instead of " "
I understand that if I set the browser meta encoding to UTF-8, these will not affect anything but I need to strip these extra characters from the database for other purposes.
For eg. :
Text: ↑ should be become Text: ?
But if I run it through utf8_decode it gives me Text: ???
For every other occurrence of the â character, it converts properly to a blank space. Any help will be appreciated.
Hi,
I have an interface named IHarvester.
There are 3 implementations of that interface, each under their own namespace:
Google
Yahoo
Bing
A HarvesterManager uses the given harvester. It knows the interface and all 3 implementations.
I want some way of letting the class user say in which harvester it wants to use. And in the code select that implementation, without a switch-case implementation.
Can reflection save my day?
Here is the code bits:
// repeat for each harvester
namespace Harvester.Google
{
public abstract class Fetcher : BaseHarvester, IInfoHarvester {...}
}
public enum HarvestingSource
{
Google,
Yahoo,
Bing,
}
class HarvesterManager {
public HarvestingSource PreferedSource {get;set;}
public HarvestSomthing()
{
switch (PreferedSource) .... // awful...
}
}
Thanks.
In scripting languages like Perl, it is possible to read a file into a variable in one shot.
open(FILEHANDLE,$file);
$content=<FILEHANDLE>;
What would be the most efficient way to do this in C++?
I have this kind of array, i will make it very simple to understand
$picture = ( 'artist2-1_thumb.jpg',
'artist2-2.jpg' ,
'artist2-3_thumb.jpg',
'artist2-4.jpg',
'artist2-5_thumb.jpg');
Now i want use substr to get new array that only have thumb, to have new array like this
$picturethumbs = ( 'artist2-1_thumb.jpg',
'artist2-3_thumb.jpg',
'artist2-5_thumb.jpg');
Can some substr but where to start?
There are the following two classes.
public class Employee
{
int EmployeeId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Street { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
}
public class Company
{
int CompanyId { get; set; }
public string Name { get; set; }
public string Street { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
}
In a DDD seminar, the speaker said the better design should be,
class PersonName
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
class Address
{
public string Street { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
}
public class Employee
{
int EmployeeId { get; set; }
public PersonName Name { get; set; }
[ForeignKey("EmployerAddress")]
public int EmployerAddressId { get; set; }
public virtual Address EmployerAddress { get; set; }
}
public class Company
{
int CompanyId { get; set; }
public string Name { get; set; }
[ForeignKey("CompanyAddress")]
public int CompanyAddressId { get; set; }
public virtual Address CompanyAddress { get; set; }
}
Is it the optimized design? How the code first generate the PersonName table and link it to Employee?
From what I know about PHP, the following syntax is not legal:
if ($s == Yes)
It should instead be written as:
if ($s == 'Yes')
However, the first example is working just fine. Anyone know why?
I have rather long entries being submitted to a database.
How can I create a function to see if this entry has a link within it? Can someone get me started?
Pretty much, I want the function to find any
I'd prefer not to throw the entry into an array. Are there any other ways to accomplish this?
Hello.
I have a file input in a form that uploads a mp3 file, but I´d like to detect conflictive characters to my system in the filename, like ! @ or any other.
All codes I´ve found replace these characters, but I just want to detect them to alert the user. I think it will be easy with regular expressions, but I dont know about them.
I´m using jquery/javascript.
Thanks in advance for your help
Edit to improve my problem description:
I´m working in a CodeIgniter application that allows user to upload mp3 files to the server.
I use jQuery to manage client side forms. The CI upload class converts spaces in the file name to underscores and everything works.
But testing the application I uploaded a mp3 file with a (!) in the name, and I got troubles with it.
I just want to insert a javascript conditional before the file is uploaded to evaluate if the user´s filename contains a (!) (or any other I´d like to add later) to ask for the file to be renamed if it does.
function SimpleSymbols(str) {
var letter =['a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var newstr = "";
for (var i = 0; i<str.length; i++){
if (str.charAt(i).toLowerCase() in letter){
newstr += "M";
}
else{
newstr += "X";
}
}
return newstr;
}
If str is "Argument goes here" it returns XXXXXXXXX. WHy doesn't it return MMMMMMMMMM?
Just using it as a method parameter is fine but what about an easy way to use it in strings?
For instance say I have this:
11 void myTest()
12 {
13 if(!testCondition)
14 logError("testcondition failed");
15 }
And I want the output to be:
"myTest line 14: testcondition failed"
How can I write logError? Does it have to be some monstrosity of a macro?
I have this snippet of the code:
set calls = `cut -d" " -f2 ${2} | grep -c "$numbers"`
set messages = `cut -d" " -f2 ${3} | grep -c "$numbers"`
@ popularity = (calls * 3) + messages
and error
@ expression syntax
what does it mean? grep -c returns number, am I wrong, thanks in advance
in $numbers I have list of numbers, 2 and 3 parameters also contain numbers
How do I use JQuery to get number from the drop down select?
<select aria-invalid="false" id="RatePercent" class="wpcf7-form-control wpcf7-select ratePercent" name="RatePercent">
<option value="">---</option>
<option value="Floating-6.5%">Floating-6.5%</option>
<option value="6 Months-5.65%">6 Months-5.65%</option>
<option value="1 Year-5.85%">1 Year-5.85%</option>
<option value="18 Months-5.99%">18 Months-5.99%</option>
<option value="2 Years-6.19%">2 Years-6.19%</option>
<option value="3 Years-6.85%">3 Years-6.85%</option>
<option value="4 Years-7.19%">4 Years-7.19%</option>
<option value="5 Years-7.40%">5 Years-7.40%</option>
</select>
If you choose 1 Year-5.85%, it returns '5.85', instead of '1 Year-5.85%'?
I think my code is too inefficient. I'm guessing it has something to do with using strings, though I'm unsure. Here is the code:
genome = FASTAdata[1]
genomeLength = len(genome);
# Hash table holding all the k-mers we will come across
kmers = dict()
# We go through all the possible k-mers by index
for outer in range (0, genomeLength-1):
for inner in range (outer+2, outer+22):
substring = genome[outer:inner]
if substring in kmers: # if we already have this substring on record, increase its value (count of num of appearances) by 1
kmers[substring] += 1
else:
kmers[substring] = 1 # otherwise record that it's here once
This is to search through all substrings of length at most 20. Now this code seems to take pretty forever and never terminate, so something has to be wrong here. Is using [:] on strings causing the huge overhead? And if so, what can I replace it with?
And for clarity the file in question is nearly 200mb, so pretty big.
I would like to repeat each line's content of a file, any quick solution using sed.
supposed the input file is
abc
def
123
The expected ouput is:
abcabc
defdef
123123
Thank you for your help
I've got the following function that manipulates an element according to the data being sent (an object).
function manipulateElem (elem, data) {
for (var key in data) {
elem[key] = data[key];
};
}
manipulateElem(document.getElementById('test'), {'href': '/home/', 'style.color': '#000000'});
As you can imagine, the later (style.color) doesn't work. How would one solve this the best way?
I get this message for as many times as I have used replaceVariables in my code. I have added the referenced libraries, but I don't know what else to do. Can someone please help me?