escaping

Data gets garbled when writing to csv with fputcsv() / fgetcsv()

我的未来我决定 提交于 2020-01-17 07:02:37
问题 There seems to be an encoding issue or bug in PHP with fputcsv() and fgetcsv(). The following PHP code: $row_before = ['A', json_encode(['a', '\\', 'b']), 'B']; print "\nBEFORE:\n"; var_export($row_before); print "\n"; $fh = fopen($file = 'php://temp', 'rb+'); fputcsv($fh, $row_before); rewind($fh); $row_after = fgetcsv($fh); print "\nAFTER:\n"; var_export($row_after); print "\n\n"; fclose($fh); Gives me this output: BEFORE: array ( 0 => 'A', 1 => '["a","\\\\","b"]', 2 => 'B', ) AFTER: array

SQLAlchemy ValueError for slash in password for create_engine() [duplicate]

﹥>﹥吖頭↗ 提交于 2020-01-16 19:36:09
问题 This question already has an answer here : Writing a connection string when password contains special characters (1 answer) Closed 2 months ago . Fairly simple-looking problem: my Python script is attempting to create a SQLAlchemy database connection. The password contains a forward slash: engineString = 'postgresql://wberg:pass/word@localhost/mydatabase' engine = sqlalchemy.create_engine(engineString) But the second line raises: ValueError: invalid literal for int() with base 10: 'pass'

Logging a literal message in NLog and/or Serilog

孤人 提交于 2020-01-16 13:18:19
问题 UPDATE: This turned out to be a discrepancy that exists in Serilog (which I tunnel to), but does not exist in NLog, which treats a single argument as a verbatim string (as one (and specifically, I) might expect) Using NLog, if I want to log something potentially containing embedded double braces: {{ without having them collapsed, what's the most efficient way? e.g.: NLog.LogManager.GetLogger("x").Warn("{{\"aaa}}") emits in my custom serilog-target: {"aaa} And I want: {{"aaa}} Is NLog

Difference between escape strings and raw strings?

和自甴很熟 提交于 2020-01-16 08:28:09
问题 In Computer Science is there any difference between a raw string and an escaped string? For me these two terms appears to be synonym, it means that all the symbols in the string will be treated a literal characters. Am I missing something? 来源: https://stackoverflow.com/questions/59627014/difference-between-escape-strings-and-raw-strings

awk embedded script issue (unexpected character '\')

时光怂恿深爱的人放手 提交于 2020-01-15 13:06:22
问题 I use an embedded awk code in a shell script: I have some variable assignments at the BEGIN part of it: \ BEGIN { FS=","; OFS=","; service_not="false"; end_of_line="\n"; is_setup_gps="false"; \ \ a=6378137.0 ; \ b=6356752.3142 ; \ f=(a-b)/a ; \ e=sqrt(f*(2-f)) ; \ } \ \ So I need '\' at the end of each line (to have an entire awk script embedded in .sh). BUT: for the lines: a=...; b=...; f=...; the '\' causing errors...: mawk: 57: unexpected character '\' Why? UPD: Embedding of awk in the

awk embedded script issue (unexpected character '\')

岁酱吖の 提交于 2020-01-15 13:04:01
问题 I use an embedded awk code in a shell script: I have some variable assignments at the BEGIN part of it: \ BEGIN { FS=","; OFS=","; service_not="false"; end_of_line="\n"; is_setup_gps="false"; \ \ a=6378137.0 ; \ b=6356752.3142 ; \ f=(a-b)/a ; \ e=sqrt(f*(2-f)) ; \ } \ \ So I need '\' at the end of each line (to have an entire awk script embedded in .sh). BUT: for the lines: a=...; b=...; f=...; the '\' causing errors...: mawk: 57: unexpected character '\' Why? UPD: Embedding of awk in the

awk embedded script issue (unexpected character '\')

时光总嘲笑我的痴心妄想 提交于 2020-01-15 13:02:16
问题 I use an embedded awk code in a shell script: I have some variable assignments at the BEGIN part of it: \ BEGIN { FS=","; OFS=","; service_not="false"; end_of_line="\n"; is_setup_gps="false"; \ \ a=6378137.0 ; \ b=6356752.3142 ; \ f=(a-b)/a ; \ e=sqrt(f*(2-f)) ; \ } \ \ So I need '\' at the end of each line (to have an entire awk script embedded in .sh). BUT: for the lines: a=...; b=...; f=...; the '\' causing errors...: mawk: 57: unexpected character '\' Why? UPD: Embedding of awk in the

printf format parameter contain undefined escape character

寵の児 提交于 2020-01-15 06:06:32
问题 #include <stdio.h> int main() { printf("Hello\c!\n"); return 0; } Output : Helloc! So , when \[some_undifined_symbol] appeared in printf 's format string, it just ignore the \ ? 回答1: \c is not an escape sequence that is already defined, but it's better to avoid using it because it's reserved: C99 §6.11.4 Character escape sequences Lowercase letters as escape sequences are reserved for future standardization. Other characters may be used in extensions. 回答2: You have the following escape

Passing double quotation marks to a command from Python using the subprocess module

江枫思渺然 提交于 2020-01-14 22:46:30
问题 I have a command line program I'm using from within a Python script to take care of stamping a build number onto an executable. This is the command line program: http://www.elphin.com/downloads/stampver/ My problem is that the program takes double quotes (") in one of its arguments and the Python subprocess module I'm using to call this program keeps prepending a backslash onto the double quotes when executing the program. This causes the program to fail due to incorrect syntax. It is

Passing double quotation marks to a command from Python using the subprocess module

孤者浪人 提交于 2020-01-14 22:45:25
问题 I have a command line program I'm using from within a Python script to take care of stamping a build number onto an executable. This is the command line program: http://www.elphin.com/downloads/stampver/ My problem is that the program takes double quotes (") in one of its arguments and the Python subprocess module I'm using to call this program keeps prepending a backslash onto the double quotes when executing the program. This causes the program to fail due to incorrect syntax. It is