保存 RTF 文本到 PostgreSQL

huangapple go评论76阅读模式
英文:

Save Rtf text in Postgresql

问题

我需要在Postgres中保存类似于这样的RTF文本{\rtf1deff0{\fonttbl。如果我尝试像这样保存,它只会保存{。看起来我需要将每个反斜杠替换为双反斜杠。尝试过像这样的方式'{\rtf1deff0{\fonttbl'但在数据库中仍然得到{

英文:

I need to save something like this RTF text '{\rtf1deff0{\fonttbl' in Postgres. If I try to save like this, it saves only '{'. It looks like I need to replace every backslash with a double backslash. Tried like this '{\rtf1deff0{\fonttbl'.replace(/\\/g, "\\") but still getting '{' in database.

update cxema_npa.reestr_npa set data = '{\rtf1deff0{\fonttbl' where cxema_npa.reestr_npa.id = 617

答案1

得分: 1

如果在将该SQL语句输入交互式数据库客户端时无法按照您的期望运行,那么您必须已将配置参数standard_conforming_strings = off设置为关闭,以便PostgreSQL将\n解释为换行符。请将该参数更改为on

如果这不是问题的原因,那么问题可能出现在您(未透露的)应用程序编程语言中。

英文:

If that SQL statement does not work as you want it to when you type it into an interactive database client, you must have set the configuration parameter standard_conforming_strings = off, so that PostgreSQL interprets \n as a newline character. Change that parameter to on.

If that is not the problem, the problem must be in your (undisclosed) application programming language.

huangapple
  • 本文由 发表于 2023年7月11日 01:45:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76656146.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定