Simulation fails when using non-ascii characters in ngspice device lib file path
The ngspice simulation of a modified laser-driver demo fails with ngspice error message Error: .include statement failed when there is a non-ascii character in the file path for a ngspice device model file.
(initiated by a user report at https://forum.kicad.info/t/librerias-spice/28780/4)
To reproduce the error, run the example file attached. It is a modified laser_driver demo, where I have moved the diode device model file laser.lib into a path \стекло\laser.lib and then attached it to the diode symbol.
The simulation is o.k. when I attach the model from the file laser.lib in the alternative path \test-lib\laser.lib.
ngspice is made to be compliant with UNICODE characters in path and file names, encoded in utf-8 format.
When I look at the ngspice netlists generated by Eeschema, I get the following netlist with the working path \test-lib\laser.lib:
.title KiCad schematic
.include "ad8009.lib"
.include "fzt1049a.lib"
.include "test-lib\laser.lib" <----------------------------------------------- o.k.
V1 /in GND pulse(0 3 100n 1n 1n 20n 100n )
R1 Net-_C1-Pad1_ GND 220
R2 Net-_R2-Pad1_ /in 160
R3 Net-_C1-Pad2_ Net-_C1-Pad1_ 220
C1 Net-_C1-Pad1_ Net-_C1-Pad2_ 1p
Q1 VDD Net-_Q1-Pad2_ Net-_C1-Pad2_ fzt1049a
R5 /out Net-_C1-Pad2_ 2.5
D1 /out GND LASER
R4 /out Net-_R2-Pad1_ 220
XU1 Net-_R2-Pad1_ Net-_C1-Pad1_ VDD VSS Net-_Q1-Pad2_ ad8009
C2 /out Net-_C1-Pad2_ 1p
V2 VDD GND DC 10
V3 GND VSS DC 10
.tran 10p 150n
.end
When I use the broken file path \стекло\laser.lib, I get
.title KiCad schematic
.include "ad8009.lib"
.include "fzt1049a.lib"
.include "" <------------------------------------------------- fail
V1 /in GND pulse(0 3 100n 1n 1n 20n 100n )
R1 Net-_C1-Pad1_ GND 220
R2 Net-_R2-Pad1_ /in 160
R3 Net-_C1-Pad2_ Net-_C1-Pad1_ 220
C1 Net-_C1-Pad1_ Net-_C1-Pad2_ 1p
Q1 VDD Net-_Q1-Pad2_ Net-_C1-Pad2_ fzt1049a
R5 /out Net-_C1-Pad2_ 2.5
D1 /out GND LASER
R4 /out Net-_R2-Pad1_ 220
XU1 Net-_R2-Pad1_ Net-_C1-Pad1_ VDD VSS Net-_Q1-Pad2_ ad8009
C2 /out Net-_C1-Pad2_ 1p
V2 VDD GND DC 10
V3 GND VSS DC 10
.tran 10p 150n
.end
The .include statement in the fourth line is followed by an empty string, thus ngspice reports a failing .include statement.
As KiCad/Eeschema will read the file from a non-ascii file path during attaching the model to the symbol, it should then transfer this path to ngspice as well.
KiCad Version
Application: KiCad Schematic Editor
Version: (5.99.0-10230-g49a91414d7), release build
Libraries:
wxWidgets 3.1.4
libcurl/7.74.0-DEV Schannel zlib/1.2.11
Platform: Windows 10 (build 19042), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
Date: Apr 12 2021 00:03:31
wxWidgets: 3.1.4 (wchar_t,STL containers)
Boost: 1.75.0
OCC: 7.5.0
Curl: 7.74.0-DEV
ngspice: 34
Compiler: Visual C++ 1928 without C++ ABI
Build settings:
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=ON
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
KICAD_SCRIPTING_ACTION_MENU=ON
KICAD_USE_OCC=ON
KICAD_SPICE=ON