I am told that Huffman coding is used as loseless data compression algorithm but also am told that real data compress software do not employ huffman coding,cause if the keys are not distributed decentralized enough,the compressed file could be even larger than the orignal file.
This leave me wondering are there any real-world application of huffman coding?
thanks.
In html source
\xE6\x82\xA0
result is "\xE6\x82\xA0"
but in php
<?php echo "\xE6\x82\xA0"; ?>
result is "?" (character for \xE6\x82\xA0 )
what can be done to make php echo \xE6\x82\xA0?
I am trying to parse an XML from a URL using the xml.sax parser. I know there are other libraries to use but coming from Java this is the one I am most familiar with and seems the least complicated to me.
The code I'm using to parse is as follows:
parser = xml.sax.make_parser()
handler = MangaHandler()
parser.setContentHandler(handler)
url = urlfetch.Fetch('http://www.mangapanda.com/alphabetical', allow_truncated = False, follow_redirects = False, deadline = False)
xml.sax.parseString(url.content, handler)
This returns a SaxException (invalid token) once the parser reaches the first & sign:
SAXParseException: <unknown>:582:34: not well-formed (invalid token)
Because urlfetch returns a string and not a stream I cannot use the parse() (which only works with streams) and am left to use parseString() instead. To see if parsing as a stream would fix this I tried:
parser.parse(io.StringIO(url.content).encode('utf-8'))
but this returns:
TypeError: initial_value must be unicode or None, not str
I have also tried to use the urllib2 libraries which do return a stream instead of urlfetch but the file is too large and is automatically truncated, leaving me with missing data.
Any Sort of work-around for this would be greatly appreciated as I've spent days getting around one obstacle just to be stopped by another.
I want these two print functions to do the same thing:
unsigned int Arraye[] = {0xffff,0xefef,65,66,67,68,69,0};
char Arrage[] = {0xffff,0xefef,65,66,67,68,69,0};
printf("%s", (char*)(2+ Arraye));
printf("%s", (char*)(2+ Arrage));
where Array is an unsigned int. Normally, I would change the type but, the problem is that most of the array is numbers, although the particular section should be printed as ASCII.
I have an application that is being expanded to the UK and I will need to add support for Latin-9 Unicode. I have done some Googling but found nothing solid as to what is involved in the process. Any tips?
Here is some code (Just the bits for Unicode stuff)
use Unicode::String qw(utf8 latin1 utf16);
# How to call
$encoded_txt = $self->unicode_encode($item->{value});
# Function part
sub unicode_encode {
shift() if ref($_[0]);
my $toencode = shift();
return undef unless defined($toencode);
Unicode::String->stringify_as("utf8");
my $unicode_str = Unicode::String->new();
# encode Perl UTF-8 string into latin1 Unicode::String
# - currently only Basic Latin and Latin 1 Supplement
# are supported here due to issues with Unicode::String .
$unicode_str->latin1( $toencode );
...
Any help would be great and thanks.
i have following string coming in the json response.
"Gas-Heizung-Sanit\u00e4r" so how to display it. i want to display that \u00e4 as a german character..
NSString *str = "Gas-Heizung-Sanit\u00e4r";
NSLog(@"%c",str);
it only prints the german character.
I can't for the life of me figure out what I'm doing wrong. It seems like it should be simple because I can't find anyone else with this issue but I can't figure out to send basic data via javascript(jQuery) to PHP and decode it. For the sake of simplicity, this is what I have:
JAVASCRIPT
var json_data = { "name" : "john doe" };
$.ajax({
type: "POST",
url: "../bin/process.php",
dataType: "json",
data: json_data
});
and my PHP FILE
$arr = json_decode("json_data", true);
$fp = fopen('data.txt', "w");
fwrite($fp, $arr['name']);
fclose($fp);
The file I'm writing ends up with nothing in it. If I do an:
fwrite($fp, 'test');
I get a file with the word test in it but no matter what I do I don't get the json data I sent.
Can someone please share a thorough example of A to Z. Thanks for any help.
Is there a way to convert a Java Image, encode it into JPEG (but not saving it to a file), and store it as an array of bytes? (byte[]) I need the JPEG-encoded image as an array of bytes.
I have done urlencode of the variable before passing to the URL
http://example.com/Restaurants?aliasF%26B
But when I try to print like in the page
$alias = rawurldecode($_GET['alias']);
echo $alias;
it prints only F. How to solve this?
I was trying to learn a bit about h264 by looking at the bitstream of a video file with a hex editor. I found here the start codes for a video object planes (0x000001b6) and for i-frames (0x000001b600).
But I can't find many of those bytes in video files. Most of the time those start codes appear at the beginning of a file with only a few bites in between. I expected them to show up very regularly, in equal distance all over the file!?
Is is even ok to look at a file with a hex editor this way? What other start codes exist and how is a h264 file organised?
Hi,
I'm using HTTP connection to share data with my JSON server.
I use URLs like "MyServlet?param1=value1" and so on...
I'm now facing a problem with one of my servlet (I can't change it because some other views are using it) :
The servlet is working with a syntax including those symbols "{" and "}".
The exact syntax is
{(value1_value2)(value3_value4)(value5_value6)}{(value7_value8)(value9_value10)(value11_value12)}{(value13_value14)(value15_value16)(value17_value18)}
Values are integers, the problem is only when I use "{" and "}" my UrlConnection returns an error for bad URL.
I use this to instantiate my NSString :
NSString *myURL = [NSString stringWithFormat:@"http://somesite.com/Servlet?PARAM={(%@)}"];
How can I code those char in my NSString ?
Thanks in advance !
I don't think i fully understand character sets so i was wondering if anyone would be kind enough to explain it in layman's terms with examples ( for Dummies).I know there is utf8, latin1, ascii ect
The more answers the better really.
Thank you in advance;-)
How to make the servlet accept non-ascii (Arabian, chines, etc) characters passed from JSPs?
I've tried to add the following to top of JSPs:
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
And to add the following in each post/get method in the servlet:
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
I've tried to add a Filter that executes the above two statements instead of in the servlet.
To be quite honest, these was working in the past, but now it doesn't work anymore.
I am using tomcat 5.0.28/6.x.x on JDK1.6 on both Win & Linux boxes.
I've just been handed a pile of Java source that, I suspect, is in ISO-8859-8. Eclipse's menu of charsets, here on my Mac, does not include that. Or any of a wide variety of other encodings supported by the JDK.
Is there a recipe for expanding the list of encodings that show up in the menu?
Simply trying to get the inline href below to not encode when run through Trang. The below run through Trang:
## See <a href="http://foo.org">foo</a> for more info
.. always comes out as:
<xs:documentation>See <a href="http://foo.org">foo</a> for more info</xs:documentation>
Hi Guys,
I was wondering about which way i should do the following. I am using the tiny MCE wysiwyg editor which formats the users data with the right html tags. Now, i need to save this data entered into the editor into a database table.
Should i encode the html tags to their corresponding entities when inserting into the DB, then when i get the data back from the table, not have the encode it for XSS purposes but i'd still have to use eval for the html tags to format the text.
OR
Do i save the html tags into the database, then when i get the data back from the database encode the html tags to their entities, but then as the tags will appear to the user, i'd have to use the eval function to actually format the data as it was entered.
My thoughts are with the first option, i just wondered on what you guys thought.
Thanks
M
What are the valid characters that can be used in a URL query variable?
I'm asking because I would like to create GUIDs of minimal string length by using the largest character set so long as they can be passed as a URL query variable (www.StackOverflow.com?query=guiddaf09834fasnv)
According to RFC 2396,
The plus "+", dollar "$", and comma
"," characters have been added to
those in the "reserved" set, since
they are treated as reserved within
the query component.
Indeed, search this site for "plus + comma , dollar $", and you get
http://stackoverflow.com/search?q=plus+%2B+comma+,+dollar+$
Plus is only encoded (by the application) when it's not being used as a delimiter.
But as others have observed, .NET's UrlDecode function converts plus to space. Where is this behavior specified?
We are currently working on a I18N project. I was just wondering what are the complications of having the non-ascii characters in the URL. If its not, what are the alternatives to deal with this problem?
EDIT (in response to Maxym's answer):
The site is going to be local to specific country and I need not worry about the world wide public accessing this site. I understand that from usability point of view, It is really annoying. What are the other technical problem associated with this?
seems like a call to
$this->_redirect('*/*/myaction',$myargs);
does not properly escape the arguments
so if
$myargs=array(p1=>'string that has + or / within it')
the created URL will be something like:
..../myaction/?p1/string%20that%20has%20+%20or%20/%20within%20it
causing the getParams collection on the action to have
p1 with value 'string that has or ' <- plus sign missing and value broken and
' within it' with no value or something similar.
is there any standard way I should handle the arguments before passing them to _redirect ?
Eyal
Trying to encode a a dict object into json using Python 2.7's json (ie: import json).
The object has some byte strings in it that are "pickled" data using cPickle, so for json's purposes, they are basically random byte strings. I was using django.utils's simplejson and this worked fine. But I recently switched to Python 2.7 on google app engine and they don't seem to have simplejson available anymore.
Now that I am using json, it throws an exception when it encounters bytes that aren't part of UTF-8. The error that I'm getting is:
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte
It would be nice if it printed out a string of the character codes like the debugging might do, ie: \u0002]q\u0000U\u001201. But I really don't much care how it handles this data just as long as it doesn't throw an exception and continues serializing the information that it does recognize.
How can I make this happen?
Thanks!
Hi
No thread about use or unuse of obfuscusion please ^^
Just share creative approaches how to obfuscate in php the really smart way plz.
plain md5 and base64_decode is too static ..
what you think regarding hash, salt
what about dynamic Variables (even for the same $var).
Thx for any creative input