This is one of those strange things that sounds a lot easier to do than it is.
I originally handled this by exploding the character through this:
$array = preg_split('//u', $a);
This worked fine and the string was split into an array of unicode characters. The next part was converting it into a useful hexidecimal value.
$character = $array[0];
$value = hexdec(bin2hex($character));
I originally thought this was the way to do so - I was wrong, don’t do it. It turns out there is no real simple way to convert from UTF-8 to hex values. Instead, try the UTF8ToUnicode function here: http://hsivonen.iki.fi/php-utf8/
Include this function and use the author’s utf8ToUnicode function. It becomes simple then:
$value = utf8ToUnicode($character);
$value = $value[0];
I am only posting this because of the sheer amount of time it took for me to find this information. I hope it helps you out.
Unfortunately, I have been stuck in a brutal losing battle against Blogger’s API. I have managed to get the authentication function working, but it stops when I try actually posting -_-
Functional Authentification Function
require_once "HTTP/Client.php";
require_once 'HTTP/Client/CookieManager.php';
$email = "blahblah";
$password = "blahblah";
$blog_id = "http://blahblah.blogspot.com/";
$source = "superman-bloggingbro-0.1";
$service = "blogger";
$login_url = "https://www.google.com/accounts/ClientLogin";
$login_params = array( "Email"=> "$email", "Passwd" => "$password", "source" => $source, "service" => $service);
$client =& new HTTP_Client();
$client->setDefaultHeader($headers2);
$client->post($login_url, $login_params);
First is my Nintendo DS site. Basically, a social web / meeting site that is mobile-enabled, it is the first time I’ve done an entire site on my own. Using the security experience I gained working for PCSafe, and the programming knowledge from Searching.com and a whole bunch of other people, I think I’ve put together something interesting/useful. Yeah, there is a lot of work yet to do, but who is to say?
There is only ONE source for decent Perl-DBI documentation online. Thank you Tony Bowden.
The important commands which seem to be available nowhere are..
$obj = Class->retrieve( $id );
$obj = Class->retrieve( %key_values );
my @objs = Class->retrieve_all;
my $iterator = Class->retrieve_all;
my @cds = Music::CD->retrieve_from_sql(qq{
artist = ‘Ozzy Osbourne’ AND
title like “%Crazy” AND
year < = 1986
ORDER BY year
LIMIT 2,3
});
If you are having problems with hashes not initializing in perl, check to make sure you are using the “{}” brackets instead of regular “()” brackets. Knowing that would have saved me 60 minutes today
The XML Parser is great - but dammit it hurts when it breaks down.
Ever get messages like this?
no element found at line 1, column 0, byte -1 at /~~~~~~/XML/Parser.pm line 187
These are the result of poorly formed feeds that screw up the XML feed. The solution is pretty simple however - use the Eval method.
eval{
(The line that calls the parser)
}
if($@){
print $feed->name, ” failed to load\n”; (depending on what your rss feed name is)
next;
}
else{
(the rest)
}
Eval catches any errors and passes them to $@. You can use this to prevent a long .pl file from crashing halfway through running.