NEW YORK (Reuters) - The U.S. dollar held steady at a six-month high against the Japanese yen and a two-month high against the Swiss franc on Thursday, bolstered by solid inflation data and investor sentiment that the greenback stands to benefit from a trade war.

FILE PHOTO: U.S. Dollar and Japan Yen notes are seen in this June 22, 2017 illustration photo. REUTERS/Thomas White/Illustration

The yen and the Swiss franc are favoured as safe-haven investments. But against the dollar, both have weakened in the past week as trade tensions between the United States and China have mounted. That suggests investors believe the greenback is better suited to withstand trade volatility, as a safe-haven investment or as a beneficiary of new policies.

“The U.S. dollar has been playing more of a role as a safe-haven,” said Juan Perez, currency trader at Tempus, Inc in Washington.

The dollar/yen rally is in its seventh trading day, with the dollar having broken through the psychologically significant barrier of 112 yen for the first time since Jan. 10 on Wednesday. On Thursday, the dollar hit a fresh six-month high against the Japanese currency of 112.62.

The Swiss franc weakened by 0.8 percent over the day, jumping over the one franc threshold; at its strongest on Thursday, 0.995 franc bought one U.S. dollar, at its weakest, it took 1.003.

“(A trade war) is probably good for the dollar,” said Greg Anderson, global head of FX strategy at BMO Capital Markets. That’s because “the U.S. has a trade deficit currency, and so if you find a way to reduce that trade deficit and you have the same financial flows, then all of the sudden, flows are going to be positive for the dollar, at least relative to where they were.”

The dollar maintained gains made on Wednesday against most major currencies thanks in part to a report of U.S. consumer prices on Thursday which showed a steady buildup of inflation pressure that could keep the Federal Reserve on a path of gradual interest rate increases.

That followed Wednesday’s report that U.S. producer prices rose in June, leading to the biggest annual increase in 6-1/2 years.

Strong economic data has underpinned the dollar’s recent strength. “(The dollar) has been kept afloat because in quarter one and quarter two the economic indicators across the spectrum were positive,” said Perez.

The eurodollar fell in overnight trade on Wednesday, retracing earlier gains, but maintained levels around $1.167 throughout Thursday.

Stock markets in China rose more than 2.6 percent and the offshore yuan climbed 0.9 percent, boosting appetite for risky assets and helping push the dollar higher.