検索

文章
· 七月 4, 2024 阅读大约需 2 分钟

ファイルに入力された文字列をバイト単位で読み込む方法

これは InterSystems FAQ サイトの記事です。

InterSystems製品のサーバサイドでファイル入出力を行うと、文字列はシステムで設定されたファイル入出力用文字コードに自動変換され、文字単位でREADします。

ファイルから入力する文字をバイト単位で操作するためには、自動変換を行わない無変換の状態でファイル入力を行い指定バイトずつ読みながら読んだ分だけUnicodeに手動で変換していく必要があります。

変換には$ZCONVERT()関数を使用します。($ZCONVERT()には省略形があり$ZCVT()でも同様の操作が行えます。)

なお、READした指定バイトを変換する際、文字の全バイトが含まれない場合もあるため、途中までの読み取りになった文字列を第4引数に指定する変数に設定できるようになっています。
次回読み取り時に途中だった文字を自動的に先頭に追加し、$ZCONVERT()の処理を実行します。

《メモ》ファイル入出力の文字コードについては、以下管理ポータルの画面で確認できます。
管理ポータル > 構成 > 国際言語設定 > 構成したデフォルト値
 入力/出力テーブルの表の「ファイル」

以下の文章がファイルにUTF8で保存されているとします。

2024/4/19:強風でしたが良い天気でした

 

無変換でファイル入力を行うには、%Stream.FileBinaryクラスを使用してファイルをオープンします。

5バイトずつ入力する例は以下の通りです。

set fb=##class(%Stream.FileBinary).%New()
write fb.LinkToFile("c:\temp\memoU.txt")  //ファイルをリンクできると1が返ります。
set data=fb.Read(5) // 5バイトずつREAD
//UTF8からUnicodeに変換するため第2引数は"I"を指定します
// 第3引数はUTF8(大文字)を指定し、第4引数に変数hadleを指定します。
//write $ZCONVERT(data,"I","UTF8",handle)," - ",handle
//EndOfFileを検出するとAtEndプロパティに1が設定されることを利用してループします。
while (fb.AtEnd=0) { set data=fb.Read(5) write $ZCONVERT(data,"I","UTF8",handle)," - ",handle,! }

kill fb  //ファイルをクローズします

While文に含まれるWRITE文の出力結果は以下の通りです。

2024/ -
4/19 - ï
:強 -
風 - ã
でし - ã
たが -
良 - ã
い天 - æ
気で -
し - ã

 - 
讨论 (0)1
登录或注册以继续
公告
· 七月 4, 2024

[Vídeo] Presentación de InterSystems Supply Chain Orchestrator

Hola Comunidad, 

Tenéis disponible un nuevo vídeo (en inglés) en el Canal de YouTube de InterSystems:

⏯ Presentación de InterSystems Supply Chain Orchestrator @ Global Summit 2023

Aprended qué contiene InterSystems Supply Chain Orchestrator. Descubrid cómo se puede utilizar para optimizar las cadenas de suministro y proporcionar información prescriptiva procesable. A través de presentaciones y una demostración en vivo de las capacidades clave del producto, aprenderéis por qué acelera el tiempo de creación de valor para la transformación digital de la cadena de suministro.

Ponentes:
🗣 @Ming Zhou, Head of Supply Chain Strategy, InterSystems
🗣 @Annie Tong, Supply Chain Sales Engineer, InterSystems

¡Disfrutadlo y estad atentos a más vídeos! 👍

讨论 (0)1
登录或注册以继续
问题
· 七月 3, 2024

Testing XML input to Router Management Portal or via XML document viewer

Trying to test a router that takes an XML input and performs a transform on it.

First attempt I tried to test the transform using the XML Document Viewer via the Ensemble -> Interoperate -> XML Document Viewer menu. The transform itself is working however I can not get the output to save to a file. I've made sure permissions are set correctly on the file. It simply doesn't output anything and I'm at a loss as to why.

As another method I also tried testing via Ensemble -> Test -> Business Hosts. Putting the file path/name as the source does not send any data. Again, I've made sure read permissions are set for the file.

I've been able to test using other methods, so I'm not concerned with actually being able to validate my transform so much as I'm now at a loss as to why the two above methods do not seem to work.

Has anyone else experienced similar issues, particularly with the XML Document Viewer method?

Thanks.

讨论 (0)1
登录或注册以继续
公告
· 七月 3, 2024

[Video] Introducing InterSystems Supply Chain Orchestrator

Hey Community,

Play the new video on InterSystems Developers YouTube:

⏯ Introducing InterSystems Supply Chain Orchestrator @ Global Summit 2023

Learn what’s inside InterSystems Supply Chain Orchestrator. Discover how it can be used to optimize supply chains and provide prescriptive actionable insights. Via presentations and a live demo of key product capabilities, you'll learn why it accelerates time-to-value for supply chain digital transformation.

Presenters:
🗣 @Ming Zhou, Head of Supply Chain Strategy, InterSystems
🗣 @Annie Tong, Supply Chain Sales Engineer, InterSystems

Enjoy watching and look out for more video content! 👍

讨论 (0)1
登录或注册以继续
问题
· 七月 3, 2024

Why does the Rule Editor display a sad face?

Hello,

I have a slight issue that's causing me some inconvenience when using the rule editor within Microsoft Edge (Version 126.0.2592.81).

Whenever I try to load up any ruleset, the ruleset displays an unhappy face like this:

This has only recently started, when opening up the rule editor in another browser e.g. Chrome, the problem disappears.

I've tried to remedy the situation by resetting Edge, Updating Edge Version, Clearing Cache/Cookies etc. but nothing seems to fix it.

I have other colleagues opening the same rule sets in the same version as Edge without any issue, so I do not believe it's an issue with the ruleset itself.

Has anyone else encountered this issue and fixed it?

Thanks.

5 Comments
讨论 (5)3
登录或注册以继续