473,804 Members | 4,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

URL decoding/encoding problem

URL decoding/encoding problem
Iif the url contains chinese char,the url will be encoded.
For example :
url:http://194.0.0.84/中文页面.htm
when my tdi driver intercept the packet, I find that "中文页面.h tm"

has been encoded to "%E4%B8%AD%E6%9 6%87%E9%A1%B5%E 9%9D%A2.htm"
when I decode it with utf8 ,the content still is not decoded;
My codes as follow:
char szMySer[MAX_PATH] ={"%E4%B8%AD%E6 %96%87%E9%A1%B5 %E9%9D%A2.htm"} ;

char *strTem =utf8_gb(szMySe r);
AfxMessageBox(s trTem);
strTem ="%E4%B8%AD%E6% 96%87%E9%A1%B5% E9%9D%A2.htm";
utf8_gb is used to decode string with utf8,it is a very correct fuction

I have used many times.
what's wrong with my code? or Do you have any good idea?
thanks.

Nov 23 '06 #1
4 3824
In article <11************ *********@j44g2 000cwa.googlegr oups.com>,
flyingco <zh*********@gm ail.comwrote:
>has been encoded to "%E4%B8%AD%E6%9 6%87%E9%A1%B5%E 9%9D%A2.htm"
when I decode it with utf8 ,the content still is not decoded;
You first have to replace each %NN with the byte value it represents
in hexadecimal, *then* interpret that sequence of bytes as UTF-8.

See RFC3986.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 23 '06 #2
"flyingco" <zh*********@gm ail.comwrote:
# URL decoding/encoding problem
# Iif the url contains chinese char,the url will be encoded.
# For example :
# url:http://194.0.0.84/=D6=D0=CE=C4=D2=B3=C3=E6.htm
# when my tdi driver intercept the packet, I find that "=D6=D0=CE=C4=D 2=B3=C3=
# =E6.htm"

Content-Type: text/plain; charset="gb2312 "
Content-Transfer-Encoding: quoted-printable

It would help if you posted plain ASCII instead of
encoded quoted printable: at the moment it's not clear
what the equal signs stand for, what is encoded in your
post and what is not.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
I ASSURE YOU WE'RE OPEN!
Nov 23 '06 #3
On 23 Nov 2006 03:22:49 -0800, "flyingco" <zh*********@gm ail.com>
wrote in comp.lang.c:
URL decoding/encoding problem
Iif the url contains chinese char,the url will be encoded.
For example :
url:http://194.0.0.84/中文页面.htm
when my tdi driver intercept the packet, I find that "中文页面.h tm"

has been encoded to "%E4%B8%AD%E6%9 6%87%E9%A1%B5%E 9%9D%A2.htm"
when I decode it with utf8 ,the content still is not decoded;
My codes as follow:
char szMySer[MAX_PATH] ={"%E4%B8%AD%E6 %96%87%E9%A1%B5 %E9%9D%A2.htm"} ;

char *strTem =utf8_gb(szMySe r);
AfxMessageBox(s trTem);
strTem ="%E4%B8%AD%E6% 96%87%E9%A1%B5% E9%9D%A2.htm";
utf8_gb is used to decode string with utf8,it is a very correct fuction

I have used many times.
what's wrong with my code? or Do you have any good idea?
thanks.
We have no idea what the utf8_gb() function is, or what is it supposed
to do. So we have no idea what you are doing wrong.

You need to ask in a group that supports this function, or perhaps one
like news:comp.os.ms windows.program mer.win32.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 24 '06 #4
thanks you very much!
utf8_gb() is a function which is used to decode the string encoded by
utf8.
utf8_gb() is a correct function I have used many times.
I am thinks about this question for this time.
"Jack Klein 鍐欓亾锛
"
On 23 Nov 2006 03:22:49 -0800, "flyingco" <zh*********@gm ail.com>
wrote in comp.lang.c:
URL decoding/encoding problem
Iif the url contains chinese char,the url will be encoded.
For example :
url:http://194.0.0.84/脰脨脦脛脪鲁脙忙.htm
when my tdi driver intercept the packet, I find that "脰脨脦脛脪鲁脙 忙.htm"

has been encoded to "%E4%B8%AD%E6%9 6%87%E9%A1%B5%E 9%9D%A2.htm"
when I decode it with utf8 ,the content still is not decoded;
My codes as follow:
char szMySer[MAX_PATH] ={"%E4%B8%AD%E6 %96%87%E9%A1%B5 %E9%9D%A2.htm"} ;

char *strTem =utf8_gb(szMySe r);
AfxMessageBox(s trTem);
strTem ="%E4%B8%AD%E6% 96%87%E9%A1%B5% E9%9D%A2.htm";
utf8_gb is used to decode string with utf8,it is a very correct fuction

I have used many times.
what's wrong with my code? or Do you have any good idea?
thanks.

We have no idea what the utf8_gb() function is, or what is it supposed
to do. So we have no idea what you are doing wrong.

You need to ask in a group that supports this function, or perhaps one
like news:comp.os.ms windows.program mer.win32.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3047
by: Matthias Stern | last post by:
Hello! I've got a Javascript-PHP encoding problem. (1) Here is the short version: ============================== I'm sending a form textfield via Javascript(!) as URL parameter (GET) from one php-page to another and want to send all possible special
40
3255
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. However when you retrieve these values into a dataset and ToString() them
0
2767
by: Johann Blake | last post by:
In my need to decode a JPEG 2000 file, I discovered like many that there was no functionality for this in the .NET Framework. Instead of forking out a pile of cash to do this, I came up with the idea that costs nothing and it is inheritently built into the Framework. So here is the solution... When you use the WebRequest and WebResponse classes to obtain graphics from a web site, these classes have built-in decoding for JPEG 2000 files....
1
2684
by: Slade | last post by:
Hi, I'm trying to use POST an image to a web page with WebRequest/WebResponse. Only problem is that I must be making an error somewhere in the encoding/decoding process. I've pasted below a bit of sample code that basically shows how I am encoding and then decoding the binary image. Many thanks if you can point out what I am doing wrong... thanks, Slade Smith Image bmp =context.GetImage();
9
23719
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the "improvements", but maybe someone here can point me in the right direction... First, it looks like asp.net will automatically read and recognize query strings encoded in utf8 and 16-bit unicode, only the latter is some mutant, non-standard...
5
6368
by: Peter Jansson | last post by:
Hello group, The following code is an attempt to perform URL-decoding of URL-encoded string. Note that std::istringstream is used within the switch, within the loop. Three main issues have been raised about the code; 1. If characters after '%' do not represent hexademical number, then uninitialized value variable 'hexint' used - this is undefined behavior. 2. This code is very inefficient - to many mallocs/string
25
3415
by: marcin.rzeznicki | last post by:
Hello everyone I've got a little problem with choosing the best decoding strategy for some nasty problem. I have to deal with very large files wich contain text encoded with various encodings. Their length makes loading contents of file into memory in single run inappropriate. I solved this problem by implementing memory mapping using P/Invoke and I load contents of file in chunks. Since files' contents are in different encodings what I...
1
1411
by: MC | last post by:
Hi! On win-XP (french), when I read subprocess (stdout), I must use differents decoding (cp1252,cp850,cp437, or no decoding), depending of the "launch mode" of the same Python's script: - from command-line - from start+run - from icon - by Python-COM-server - etc.
9
8820
by: KWSW | last post by:
Having settled the huffman encoding/decoding and channel modeling(thanks to the previous part on bitwise operation), the last part would be hamming encoding/decoding. Did some research as usual on hamming codes and how they work(well sort of) I got a general idea how to start constucting a (7,4) hamming code. Unfortunately I have no idea how to start on the decoding/error correcting part and some direction would be nice. --- for...
0
1831
by: Michele | last post by:
Hi there, I'm using a python script in conjunction with a JPype, to run java classes. So, here's the code: from jpype import * import os import random import math import sys
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we抣l explore What is ONU, What Is Router, ONU & Router抯 main usage, and What is the difference between ONU and Router. Let抯 take a closer look ! Part I. Meaning of...
0
10575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10076
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project梡lanning, coding, testing, and deployment梬ithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3816
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.