# How to make XXXReader to support chinese file path under windows 7?

**URL:** https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715
**Category:** Support
**Created:** [June 13, 2022, 10:32am UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715 "2022-06-13T10:32:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![AlexLuya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alexluya/32/4036_2.png) [@AlexLuya](https://discourse.vtk.org/u/AlexLuya)
#### Post date: [June 13, 2022, 10:32am UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715/1 "2022-06-13T10:32:14Z")

</div>

Hello,this code:

> OBJReader reader=OBJReader::New();  
> reader-\>SetFileName(“c://user/用户/中文/model.obj”);  
> //reader-\>SetFileName(“/home/user/中文/model.obj”); //for linux  
> reader-\>Update();  
> auto data = reader-\>GetOutput();

(vtk 9.1 is being used)

works properly under Windows 10(set UTF8 support in region setttings) and linux,but doesn’t work under windows 7.

How to make it work under windows 7(maybe all pre windows 10)?

---

<div class="post-metadata">

### Author: ![mau\_igna\_06](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mau_igna_06/32/8064_2.png) [@mau\_igna\_06](https://discourse.vtk.org/u/mau_igna_06)
#### Post date: [June 13, 2022, 3:19pm UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715/2 "2022-06-13T15:19:07Z")

</div>

Please try this

> **[Does WebWidget's printToPdf work on Mac?](https://discourse.slicer.org/t/does-webwidgets-printtopdf-work-on-mac/19544/7)**
>
> Looks like file:/// is the right thing - it works on mac and should also work on windows. But if you really need it: \>\>\> slicer.app.os 'macosx'

And see if it helps

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [June 14, 2022, 4:48am UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715/3 "2022-06-14T04:48:43Z")

</div>

> [@AlexLuya](#):
>
> works properly under Windows 10(set UTF8 support in region setttings) and linux,but doesn’t work under windows 7.

Users cannot expect your application to support Windows 7 anymore. Even Microsoft dropped support for Windows 7 several years ago. Upgrading is not a personal preference because anybody using an operating system without security updates puts all computers in his entire organization at risk.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [June 14, 2022, 4:54am UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715/4 "2022-06-14T04:54:17Z")

</div>

This should work out of the box on Windows 7. Does the path exist?

You have to encode text in utf8 format. Try  
`reader->SetFileName(u8"c://user/用户/中文/model.obj")`

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 14, 2022, 1:23pm UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715/5 "2022-06-14T13:23:29Z")

</div>

Are those paths hardcoded? If yes, then make sure your editor is saving the text characters properly (UTF-8). Also, it may look correct on screen and in the file, but can be misinterpreted by the compiler. So you need to tell the compiler how to read correctly whatever is enclosed by the quotation marks. Maybe prepending those hardcoded paths with an **L** in your source code (e.g. `L"c://user/用户/中文/model.obj`") will do.

> <https://stackoverflow.com/questions/15962259/chinese-character-in-source-code-when-utf-8-settings-cant-be-used>

---

<div class="post-metadata">

### Author: ![AlexLuya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alexluya/32/4036_2.png) [@AlexLuya](https://discourse.vtk.org/u/AlexLuya)
#### Post date: [June 17, 2022, 7:37am UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715/6 "2022-06-17T07:37:14Z")

</div>

No,path string comes from a file selector of windows,it is a variable,not a hard coded string.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [June 17, 2022, 7:45am UTC](https://discourse.vtk.org/t/how-to-make-xxxreader-to-support-chinese-file-path-under-windows-7/8715/7 "2022-06-17T07:45:29Z")

</div>

VTK works with utf8 on all versions of Windows. You can’t rely on regional settings for Windows before version 10.

Is the path obtained by the command line args in `main()`? You need to use GetCommandLineW (or `wmain()`) and covert the UTF-16 text to UTF-8.

Otherwise whatever Windows API function is supplying the text needs to be the W version (not the A version) and then do the conversion in your own code.
