[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Unicode/UTF-8 confusion

Carsten Haese

3/16/2008 6:54:00 AM

On Sat, 2008-03-15 at 16:33 -0400, Tom Stambaugh wrote:
> I appreciate the answers the community has provided, I think I need to add
> some additional context.
> [...]
> var aSerializedObject = '%(jsonString)s';
> [...]
> Once back in the browser, the loadObject method calls JSON.parse on
> aSerializedObject, the json string we're discussing.
> [...]
> In order to successfully pass the escapes to the server, I already have to
> double any each backslash. At the end of the day, it's easier -- and results
> in better performance -- to convert each apostrophe to its unicode
> equivalent, as I originally asked.
> [...]

It helps to ask for what you really need instead of asking for what you
think you need. The above helps in that it outlines the source of your
confusion.

What you don't realize is that you're really doing two JSON-encode steps
on the server side, and two JSON-decode steps on the client side. You
have two decode steps because sticking a JSON-string on the right-hand
side of a JavaScript expression will parse that string in the same way a
JSON parser would. That's an implicit JSON-decode, and later you're
explicitly decoding the result of that implicit decode.

You also have two JSON-encode steps. One is an explicit encode step
using simplejson.dumps, and the other is an implicit encode done by a
semi-functional mishmash of double-backslashes and wrapping the string
in apostrophes. As you have discovered, that doesn't work so well when
the string already contains apostrophes.

What I suggest you try is this:
1) Get rid of the apostrophes in '%(jsonString)s'.
2) Get rid of all the manual escaping.
2) Send the result of simplejson.dumps through a second simplejson.dumps
step.

Alternatively, you could try this:
1) Get rid of the apostrophes in '%(jsonString)s'.
2) Get rid of all the manual escaping.
2) Get rid of the JSON.parse step on the browser side.

The first alternative accomplishes that you correctly JSON-encode twice
and correctly JSON-decode twice. The second alternative accomplishes
that you only encode and decode once.

Hope this helps,

--
Carsten Haese
http://informixdb.sourc...


4 Answers

rst9

4/18/2013 2:54:00 AM

0

Satish, you're only good at raping and killing Indian women.
You don't have any brain for anything else.

rst0wxyz

4/18/2013 4:25:00 PM

0

Go rape and kill Indian women. That is the only thing you can do
well, Satish.
You are too stupid to know any better.

Uncle Sam is beating his war drum. You pawns must get in steps with
the war-drum.

Satish

4/19/2013 2:17:00 PM

0

On Apr 18, 9:25 am, rst0 <rst0w...@yahoo.com> wrote:
> Go rape and kill Indian women.  That is the only thing you can do
> well, Satish.
> You are too stupid to know any better.
>
> Uncle Sam is beating his war drum.  You pawns must get in steps with
> the war-drum.

rst0/9, I hope you are beginning to realize that to be a paid agent of
the Chinese Communist Party (CCP) dictatorship in Beijing while
residing in the safe haven on Twilight Avenue in Merced, CA carries
its price.


Your hate mongering against USA has resulted in the death of an
innocent Chinese student. Some day it might boomerang on you too. If
the terrorists you cheer can hit Boston, they can hit Merced, CA just
as well. Try to be a patriotic American for a change.


http://img16.imageshack.us/img16/3928/chin... ;

*****************

http://en.wikipedia.org/wiki/50_...

50 Cent Party

The 50 Cent Party are Internet commentators (?????, ?????, wanglù
pínglùn yuán) hired by the government of the People's Republic of
China (both local and central) or the Communist Party to post comments
favorable towards party policies in an attempt to shape and sway
public opinion on various Internet message boards. The commentators
are said to be paid for every post that either steers a discussion
away from anti-party or sensitive content on domestic websites,
bulletin board systems, and chatrooms, or that advances the Communist
party line.

****************


75-year old rst0/rst9 will do himself a big favor if he enrolls
himself in some adult education school and also for some anger
management courses. Otherwise patriotically challenged rst0 will lose
his mind completely and continue to make a spectacle of himself by
revealing his appalling ignorance in everything from history to
English. And if rst0/rst9 can't get himself to do that, he should stop
bilking USA and go back to where his heart really resides, namely, the
village of his birth in China under CCP-dictatorship. That would be
the honest thing to do. Of course, it is another matter that his gf
will refuse to follow rst0 to CCP-land where any deviation of his
newsgroup posts from the official CCP-line will right away lead him to
re-education through labor ( ???? ).


Chinese-Americans are by and large a patriotic lot. But there are a
few bad apples who go proactive with their bid to serve the colonial
agenda of CCP-dictatorship. These bad apples had often worked with
defense contractors like Lockheed, Boeing etc. but when opportunity
came they betrayed USA by selling company and US secrets to the CCP-
dictatorship. When caught with their pants down, these bad apples
inevitably landed in jail.


rst0, USA respects your freedom of speech. Unlike the CCP-dictatorship
in China, the US government is not going to monitor your posts on the
newsgroup and go after you for your rantings on the internet. You can
bark with impunity without any fear of reprisal by the US government.
But you will make a grave mistake if you ever try to bite the hand
that feeds you by selling Lockheed and US secrets to the CCP-
dictatorship. You will be eventually caught and spend the rest of your
golden years inside jail cells.


Try to be like the normal Chinese-Americans. Ambassador Gary Locke is
a good role model. He has won nothing but admiration from the
ordinary Chinese under CCP-dictatorship.He is far more respected by
the ordinary folks in China than the stinking fat cats in the party
politburo.


As a retired 75-year old, you have ample time in your hand. Your idle
brain has become the devil's workshop. You are 24/7 on the internet
pushing the evil agenda of the CCP-dictatorship in China. But if you
have any brain, you will bark but not bite to avoid ending up in jail
like a few Chinese Americans have for selling US to the CCP-
dictatorship in China for pecuniary gains.


China-born aerospace engineer Dogfang Greg Chung is the same age as 75-
year old rstx. rstx would be wise to steer himself away from the path
of treason that has earned the 75-year old Dongfan Gref Chung a 15
year prison sentence. Here's Dogfang Greg Chung's shameful story:


************************


http://articles.latimes.com/print/2010/feb/09/local/la-me-chinese-spy9...


9-2-2010


Chinese-born engineer gets 15 years in spying for China
Dongfan 'Greg' Chung, who worked with Boeing and Rockwell
International, was accused of providing information on the space
shuttle and Delta IV rocket.
By Patrick J. McDonnell


A Chinese-born aerospace engineer who had access to sensitive material
while working with a pair of major defense contractors in Southern
California was sentenced Monday to more than 15 years in prison for
acquiring secret space shuttle data and other information for China.


U.S. District Judge Cormac J. Carney in Santa Ana imposed a 188-month
prison term on Dongfan "Greg" Chung, 73, a naturalized U.S. citizen
who lives in Orange.


Carney declared that he could not "put a price tag" on national
security and sought to send a signal to China to "stop sending your
spies here," according to the U.S. attorney's office.


Chung, who worked at Boeing's Huntington Beach plant, denied being a
spy and said he was gathering documents for a book, not for espionage.
His attorneys argued that much of the material was already available
on the public record.


At his sentencing, Chung professed his love for the United States,
even as prosecutors depicted him as a spy who would compromise U.S.
national security.


"Giving China advanced rocket technology is not in the United States'
national interest," said Assistant U.S. Atty. Greg Staples. "There is
a voracious appetite for U.S. technology in China."


Whether loyalty to his homeland or financial gain was Chung's motive
remained unclear. The case is one of a number of prosecutions that
have shed light on alleged Chinese efforts to gain access to U.S.
technology and research through espionage.


Chung was the first suspect tried with attempting to help a foreign
nation under the terms of the 1996 Economic Espionage Act, passed to
help prevent pilfering of sensitive economic information. Chung chose
to have the case heard by the judge rather than a jury.


Chung was convicted last year on charges of economic espionage and
acting as an agent for more than three decades while employed by
Rockwell International and Boeing Co.


When Chung was convicted, Carney said the case revealed Chung's
"secret life" as a "spy" for China. The case against him arose from an
investigation into another engineer, Chi Mak, who worked in the United
States and obtained sensitive military information for China. Mak and
several relatives were convicted of providing defense information to
China, the U.S. attorney's office said. Carney sentenced Mak to more
than 24 years in prison in 2008.


Federal authorities said Chung stole restricted technology and trade
secrets, including data related to the space shuttle and the Delta IV
rocket.


"This case demonstrates our resolve to protect the secrets that help
protect the United States, as well as the important technology
advancements developed by scientists working for companies that
provide crucial support to our national security programs," acting
U.S. Atty. George S. Cardona said Monday in a statement.


Chung held a "secret" security clearance when he worked at Rockwell
and Boeing on the space shuttle program, authorities said. He retired
in 2002 but the next year returned to Boeing as a contractor, a
position he held until September 2006, the U.S. attorney's office
said.


Between 1985 and 2003, Chung made trips to China to deliver lectures
on technology involving the space shuttle and other programs, the
government said. During those trips, Chung met with Chinese government
officials, including military agents, U.S. authorities said.




http://articles.latimes.com/print/2010/feb/09/local/la-me-chinese-spy9...



********************

http://www.washingtonpost.com/world/national-security/chinese-citizen-sentenced-in-military-data-theft-case/2013/03/25/dc4567fa-9593-11e2-ae32-9ef60436f5c1_...

Washington Post
March 25, 2013

Chinese citizen sentenced in military data-theft case
By Peter Finn, Published: March 25

NEWARK, N.J. — Measured in millimeters, the tiny device was designed
to allow drones, missiles and rockets to hit targets without satellite
guidance. An advanced version was being developed secretly for the
U.S. military by a small company and L-3 Communications, a major
defense contractor.

On Monday, Sixing Liu, a Chinese citizen who worked at L-3’s space and
navigation division, was sentenced in federal court here to five years
and 10 months for taking thousands of files about the device, called a
disk resonator gyroscope, and other defense systems to China in
violation of a U.S. arms embargo.

The case illustrates what the FBI calls a growing “insider threat”
that hasn’t drawn as much attention as Chinese cyber operations. But
U.S. authorities warned that this type of espionage can be just as
damaging to national security and American business.

“The reason this technology is on the State Department munitions list,
and controlled .?.?. is it can navigate, control and position
missiles, aircraft, drones, bombs, lasers and targets very
accurately,” said David Smukowski, president of Sensors in Motion, the
small company in Bellvue, Wash., developing the technology with L-3.
“While it saves lives, it can also be very strategic. It is rocket
science.”

Smukowski estimated that the loss of this tiny piece of technology
alone could ultimately cost the U.S. military hundreds of millions of
dollars.

In the past four years, nearly 100 individual or corporate defendants
have been charged by the Justice Department with stealing trade
secrets or classified information for Chinese entities or exporting
military or dual-use technology to China, according to court records.
A number of other cases involving China remain under seal, according
to the Justice Department.

The targets of all this theft are some of the biggest and best-known
U.S. defense contractors and private companies, with household names
such as Northrop Grumman, Boeing, General Dynamics, Ford, DuPont and
Dow Chemical.

“America is a global leader in the development of military
technologies and, as such, it has become a leading target for the
theft and illicit transfer of such technologies,” said John Carlin,
acting assistant attorney general for national security. “These
schemes represent a threat to our national security. The intelligence
community has assessed China to be among the most aggressive
collectors of sensitive U.S. information and technologies and our
criminal prosecutions across the country reflect that assessment.”

Earlier this month, a Chinese citizen who worked as a contractor at
NASA’s Langley Research Center was arrested at Dulles Airport and
charged with making false statements to federal agents about the
laptop and SIM card he was carrying. According to an FBI affidavit,
the suspect, Bo Jiang, 31, had taken a NASA laptop that contained
sensitive information on a previous trip to China.

Following the arrest, Maj. Gen. Charles F. Bolden Jr., the NASA
administrator, told a House committee that he was limiting access to
NASA for the citizens of several countries, including China, pending a
full security review.

In a classic espionage case, a 59-year-old former Army defense
contractor in Hawaii was charged this month with passing classified
information to his 27-year-old Chinese lover whom he first met at a
military conference.

Benjamin Pierce Bishop, a former Army officer with a top-secret
security clearance, worked at U.S. Pacific Command as a contractor. He
is accused of turning over information about nuclear weapons, missile
defense, and radar systems. The woman may have attended the conference
“to target individuals .?.?. who work with and have access to U.S.
classified information,” according to an FBI affidavit.

Last year, the FBI began a public campaign to alert the defense
industry and other businesses to the “insider threat.” As part of the
effort, billboards were placed along commuter corridors near nine
leading research centers.

C. Frank Figliuzzi, the former head of the FBI’s Counterintelligence
Division, told Congress last year that perhaps the most important
measure against the theft of proprietary information “is identifying
and taking defensive measures against employees.”

Liu, who holds a doctorate in electrical engineering, came to the
United States in 1993 and held a series of jobs at Bandag and Primex,
tire manufacturers, and John Deere. In 2009, he went to work at L-3’s
space and navigation division in northern New Jersey, where he was
part of a team of engineers testing the technology created by Sensors
in Motion, a pioneer in gyroscope-based navigation and guidance
systems.

Liu made two trips to China, in 2009 and 2010, and each time he made
several presentations on the technology he was working on without the
permission of his employers, according to prosecutors. Before the
second trip, in November 2010, Liu made an electronic archive of his
work e-mail and transferred it to his personal computer along with the
entire Sensors in Motion program folder, according to court records.

Liu told his supervisor he was going on vacation to Chicago, but
instead he spent more than two weeks in China, speaking at a
technology conference organized by the Chinese government and Chinese
universities, prosecutors said.

Federal prosecutors said that Liu was in China to use his knowledge
about cutting-edge defense technology get a job at a premier Chinese
aeronautical institute. Along with thousands of proprietary documents,
Liu’s computer contained a lengthy résuméof 25 projects on which he
had worked for L-3; each project was identified by its connection to
the U.S. military, according to court records.

Liu was stopped on his return from China in November 2010 and
eventually arrested in March 2011. After a jury trial, Liu was
convicted last September of violating the Arms Export Control Act and
possessing and transporting stolen trade secrets.

In court Wednesday, Liu, the 50-year-old father of three, including
two U.S. citizens, told the judge that he did not intend to harm the
United States and suggested that the case was a political prosecution.

Addressing the judge before sentencing, he said he had a message for
his children, “Believe me, Daddy didn’t do anything.”

Liu’s attorney, James D. Tunick, interrupted his client’s rambling
speech several times, apparently to get Liu to tone down assertions
that the case was political. Tunick had previously argued that Liu
“only revealed very limited information in China” and the downloaded
documents were for the scientist’s “own personal knowledge.”

“Doctor, this is not a political prosecution,” said U.S. District
Court Judge Stanley R. Chesler who ruled that Liu’s actions benefited
the Chinese government. He noted that Liu downloaded documents for
programs in which he had no involvement, though the judge said Liu
knew “just how sensitive the material he had was.”

When FBI agents raided Liu’s house in March 2011, they found
proprietary material from Bandag, Primex and John Deere as well as
L-3. “We believe Sixing Liu was a serial thief,” said Assistant U.S.
Attorney L. Judson Welle, who had asked for an eight-year sentence.

Officials from the other companies declined to comment or did not
respond to requests from The Washington Post. But Smukowski of Sensors
in Motion said: “What a tragedy all around. For us, for him, and for
American technology prowess.”


*******************



http://www.newser.com/article/da0v55100/chinese-born-american-sentenced-to-4-years-in-prison-for-stealing-trade-secrets-from-mot...

AFP
August 29, 2012

Chinese-born American sentenced to 4 years in prison for stealing
trade secrets from Motorola
Motorola trade secrets thief gets 4-year term
By JASON KEYSER

A Chinese-born American convicted of stealing trade secrets from
Motorola was sentenced Wednesday to 4 years in prison in a case that
prosecutors hoped would send a message to those who might be tempted
to siphon vital information from U.S. companies.

Hanjuan Jin, who worked as a software engineer for Motorola Inc. for
nine years, was stopped during a random security search at O'Hare
International Airport on Feb. 28, 2007, before she could board a
flight to China. Prosecutors say she was carrying $31,000 and hundreds
of confidential Motorola documents, many stored on a laptop, four
external hard drives, thumb drives and other devices.

U.S. District Judge Ruben Castillo found Jin guilty in February of
stealing trade secrets but acquitted her of more serious charges of
economic espionage, explaining that the evidence fell short of proving
she stole the information on behalf of a foreign government or entity.

Prosecutors alleged that among the secrets she carried were
descriptions of a walkie-talkie type feature on Motorola cellphones
that prosecutors argued would have benefited the Chinese military.

Jin's lawyers say the naturalized U.S. citizen was not an agent of
China and took the files merely to refresh her knowledge after a long
absence from work. They asked the judge for probation and said in a
court filing last week that "Jin has overwhelming remorse and regret"
for her actions and "continues to suffer from the collateral
consequences of her admittedly poor choice."

After her conviction, prosecutors said they hoped the ruling would
send a message that such crimes come with heavy penalties. They said
they also hoped the trial would demonstrate to U.S. companies that
they can report such crimes and not risk their trade secrets being
revealed in court.

Prosecutors say the former University of Notre Dame graduate student
began downloading files at her Chicago-area Motorola office after
returning from an extended medical leave just a few days earlier.

During the trial, prosecutor Christopher Stetler told the court that
Jin "led a double life" as a seemingly loyal company worker who was
actually plotting to steal her employer's secrets.

Even before returning to Motorola to download files over the several
days in February 2007 prosecutors say Jin had already begun working
for China-based Sun Kaisens, a telecommunications firm that government
attorneys say develops products for China's military.

But the defense insisted Jin harbored no ill intent and merely grabbed
the files to refresh her technical knowledge after her long absence
from work. They also said prosecutors overvalued the technology in
question, saying the walkie-talkie feature is no longer cutting edge
and would have been of little military value.

In his February ruling, Judge Castillo wrote that the government
hadn't met several requirements to prove economic espionage, including
clearly demonstrating that Jin knew the materials she stole could
benefit China or its military.

Jin was allowed to remain free pending Wednesday's sentencing, though
she had to wear electronic monitoring and was confined to her Aurora
home.

Motorola Inc. has since become Motorola Solutions Inc., in suburban
Schaumburg.

*************

rst9

4/19/2013 4:08:00 PM

0

Go rape and kill Indian women. That is the only thing you can do
well, Satish.
You are too stupid to know any better.
Uncle Sam is beating his war drum. You pawns must get in steps with
the war-drum.