escaping

File content to single JSON string value with bash

依然范特西╮ 提交于 2020-07-20 11:43:09
问题 I would like to read a file and put the whole content into a single string that is escaped to be used in a JSON object. And I want to do it on the commandline/terminal (Linux). 回答1: Version 1 jq -n \ --arg content "$(cat theFile.txt)" \ '{ theContent : $content }' \ | \ jq '.theContent' Version 2 Jeff Mercado provided a more compact solution for the first part - so I adapted that in my code as follows: jq -Rs \ '{ theContent: . }' \ theFile.txt \ | \ jq '.theContent' Version 3 Now Jeff

Inserting a formula containing an ampersand into a cell

感情迁移 提交于 2020-07-19 19:04:09
问题 I'm trying to create a formula in the A1 cell which contains an ampersand character that looks something like this in Excel: ="Hello, "&A2 My VBA code is as follows: Worksheets("Sheet1").Range("A1").Formula = "=""Hello, "" & "&A2" VBA is throwing errors, and I can't figure out why. I've tried using double ampersands, and double quotes in various places and can't get around this error. 回答1: Consider: Sub dural() Range("A1").Formula = "=" & Chr(34) & "Hello" & Chr(34) & "& A2" End Sub 回答2:

Inserting a formula containing an ampersand into a cell

我的未来我决定 提交于 2020-07-19 19:02:05
问题 I'm trying to create a formula in the A1 cell which contains an ampersand character that looks something like this in Excel: ="Hello, "&A2 My VBA code is as follows: Worksheets("Sheet1").Range("A1").Formula = "=""Hello, "" & "&A2" VBA is throwing errors, and I can't figure out why. I've tried using double ampersands, and double quotes in various places and can't get around this error. 回答1: Consider: Sub dural() Range("A1").Formula = "=" & Chr(34) & "Hello" & Chr(34) & "& A2" End Sub 回答2:

How to escape double and single quotes in YAML within the same string

房东的猫 提交于 2020-07-17 03:25:26
问题 I need to properly escape single and double quotes in an ansible playbook in order to set the environment variable. None of this works: - name: Set environment variable command: > export EXTRA_CONFIG=“'”{"client": {"subscriptions": ["DIND-Worker"], "cluster": "internal"}}“'” - name: Set environment variable command: > export EXTRA_CONFIG=''{"client": {"subscriptions": ["DIND-Worker"], "cluster": "internal"}}'' - name: Set environment variable command: > export EXTRA_CONFIG=''{\"client\": {\

Exactly how do backslashes work within backticks?

一世执手 提交于 2020-07-15 04:29:35
问题 From the Bash FAQ: Backslashes (\) inside backticks are handled in a non-obvious manner: $ echo "`echo \\a`" "$(echo \\a)" a \a $ echo "`echo \\\\a`" "$(echo \\\\a)" \a \\a But the FAQ does not break down the parsing rules that lead to this difference. The only relevant quote from man bash I found was: When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by $, `, or . The "$(echo \\a)" and "$(echo \\\\a)" cases are easy enough:

Convert escaped characters with python

╄→尐↘猪︶ㄣ 提交于 2020-06-29 08:40:46
问题 First sorry for my english I have to convert strings from a json file like the following: {"detalle":"el Expediente N\u00b0\u00a030 de la Resoluci\u00f3n 11..."} In something like: {"detalle":"el Expediente N° 30 de la Resolución 11..."} to then write it in a txt. I tried: json.dumps({"detalle":"el Expediente N\u00b0\u00a030 de la Resoluci\u00f3n 11..."}, ensure_ascii=False).encode('utf8') that returns '{"detalle": "el Expediente N\\\\u00b0\\\\u00a030 de la Resoluci\\\\u00f3n 11..."}' How can

Convert escaped characters with python

狂风中的少年 提交于 2020-06-29 08:40:31
问题 First sorry for my english I have to convert strings from a json file like the following: {"detalle":"el Expediente N\u00b0\u00a030 de la Resoluci\u00f3n 11..."} In something like: {"detalle":"el Expediente N° 30 de la Resolución 11..."} to then write it in a txt. I tried: json.dumps({"detalle":"el Expediente N\u00b0\u00a030 de la Resoluci\u00f3n 11..."}, ensure_ascii=False).encode('utf8') that returns '{"detalle": "el Expediente N\\\\u00b0\\\\u00a030 de la Resoluci\\\\u00f3n 11..."}' How can

curl file upload with semicolons in filename

孤街浪徒 提交于 2020-06-16 17:20:08
问题 I'm implementing an automated, command line file uploader using curl to a servlet. The problem is, I've got tens of thousands of files with semicolons (;) in the filenames. I'm well aware of the annoyance of this but it is a legacy app that continues to produce new files each day. Renaming is not really an option for compatibility reasons downstream. I've tried quoting, escaping, converting to "%3b", fully qualifying the path... the obvious stuff... but nothing seems to work, and it fails to

curl file upload with semicolons in filename

試著忘記壹切 提交于 2020-06-16 17:18:55
问题 I'm implementing an automated, command line file uploader using curl to a servlet. The problem is, I've got tens of thousands of files with semicolons (;) in the filenames. I'm well aware of the annoyance of this but it is a legacy app that continues to produce new files each day. Renaming is not really an option for compatibility reasons downstream. I've tried quoting, escaping, converting to "%3b", fully qualifying the path... the obvious stuff... but nothing seems to work, and it fails to

Why do backslashes need to be escaped in JPA native queries?

百般思念 提交于 2020-06-15 18:53:27
问题 In JPA, when executing a native query, I have to escape backslash characters to double backslash. E.g. when having a where clause like UPPER(app.NAME) like UPPER(?) escape '\' then I need to create a string which contains: UPPER(app.NAME) like UPPER(?) escape '\\' Then I run a native query using openJPA 2.2.2: final EntityManager entityManager = EntityManagerFinder.getEntityManager(); final Query query = entityManager.createNativeQuery(sql, Response.class); The SQL statement is read from XML