suggest source file format to utf-8

zombielei

20-09-2011 11:08:20

Hi, everyone.
Recently i svn checkout the trunk code.
When i compile the code vs2010 complains: "warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss".And each time when i open a code file vs2010 pop a line ending inconsistent dialog and change the file automatically,if i save the file,svn working copy changed and interfere with my code experiment.
Thanks for reading and apologize for inappropriate words and phrase.

Altren

20-09-2011 20:34:07

Hm, we used to keep utf-8 encoding and usually set svn-eol:native option in svn, that keep native and consistent line ending for all files. Could you point files, which have non-utf characters and files with non-consistent end of line characters.

zombielei

21-09-2011 05:23:01

Hm, we used to keep utf-8 encoding and usually set svn-eol:native option in svn, that keep native and consistent line ending for all files. Could you point files, which have non-utf characters and files with non-consistent end of line characters.
I've just found some files like MyGUI_Widget.cpp encoding as utf-8 with no BOM, and some are windows-1251 encoding.so i upload my build log.
thank you.

Altren

21-09-2011 09:13:06

Thanks, I see the problem now. I tried you patch, that you uploaded first, but as you mentioned - some files already in utf8 without BOM, so it was wrong. Could you make a patch with all files converted into utf8 without BOM?

zombielei

21-09-2011 10:34:25

Thanks, I see the problem now. I tried you patch, that you uploaded first, but as you mentioned - some files already in utf8 without BOM, so it was wrong. Could you make a patch with all files converted into utf8 without BOM?
This is it,may be some mistakes because i do by hand.Thanks.

I've just found the patch i created can't apply to trunk,error: "An unknown line type was found in line 180!".Do you have the same problem?

zombielei

21-09-2011 11:50:27

I found the patch i created didn't work, so use the following c# code:

static void TranslateFileToUtf8(string path)
{
Encoding encoding = Encoding.GetEncoding("windows-1251");
string s = File.ReadAllText(path, encoding);

UTF8Encoding utfencoding = new UTF8Encoding(false);
File.WriteAllText(path, s, utfencoding);
}

static void Main(string[] args)
{
System.Environment.CurrentDirectory = @"D:\libs\my-gui\trunk";
string[] files =
{
"Common/Base/DirectX11/BaseManager.cpp",
"Common/Base/DirectX11/BaseManager.h",
"Common/Base/DirectX/BaseManager.cpp",
"Common/Base/DirectX/BaseManager.h",
"Common/Base/Ogre/BaseManager.cpp",
"Common/Base/Ogre/BaseManager.h",
"Common/Base/OpenGL/BaseManager.cpp",
"Common/Base/OpenGL/BaseManager.h",
"Common/BaseLayout/Attribute.h",
"Common/BaseLayout/BaseLayout.h",
"Common/Input/InputConverter.h",
"Common/Input/Win32/InputManager.cpp",
"Common/Input/Win32/PointerManager.cpp",
"Common/MessageBox/MessageBox.h",
"Common/MessageBox/MessageBoxStyle.h",
"Common/PanelView/BasePanelView.h",
"Common/PanelView/BasePanelViewItem.h",
"Demos/Demo_Colour/ColourPanel.cpp",
"Demos/Demo_Console/Console.cpp",
"Demos/Demo_Console/Console.h",
"Demos/Demo_ItemBox/DemoKeeper.cpp",
"Demos/Demo_ItemBox/ToolTip.cpp",
"Demos/Demo_Pointers/ControlPanel.cpp",
"Demos/Demo_Pointers/DemoKeeper.cpp",
"Demos/Demo_Pointers/PointerContextManager.cpp",
"MyGUIEngine/include/MyGUI_Common.h",
"MyGUIEngine/include/MyGUI_CommonStateInfo.h",
"MyGUIEngine/include/MyGUI_FontData.h",
"MyGUIEngine/include/MyGUI_ILayer.h",
"MyGUIEngine/include/MyGUI_ILayerNode.h",
"MyGUIEngine/include/MyGUI_LogLevel.h",
"MyGUIEngine/include/MyGUI_Macros.h",
"MyGUIEngine/include/MyGUI_OverlappedLayer.h",
"MyGUIEngine/include/MyGUI_PolygonalSkin.h",
"MyGUIEngine/include/MyGUI_RenderItem.h",
"MyGUIEngine/include/MyGUI_RenderManager.h",
"MyGUIEngine/include/MyGUI_ResourceManualFont.h",
"MyGUIEngine/include/MyGUI_RotatingSkin.h",
"MyGUIEngine/include/MyGUI_ScrollViewBase.h",
"MyGUIEngine/include/MyGUI_SharedLayer.h",
"MyGUIEngine/include/MyGUI_SkinItem.h",
"MyGUIEngine/include/MyGUI_SubWidgetInfo.h",
"MyGUIEngine/src/MyGUI_BiIndexBase.cpp",
"MyGUIEngine/src/MyGUI_FontManager.cpp",
"MyGUIEngine/src/MyGUI_LayerItem.cpp",
"MyGUIEngine/src/MyGUI_MenuItem.cpp",
"MyGUIEngine/src/MyGUI_OverlappedLayer.cpp",
"MyGUIEngine/src/MyGUI_PolygonalSkin.cpp",
"MyGUIEngine/src/MyGUI_ResourceImageSetPointer.cpp",
"MyGUIEngine/src/MyGUI_ResourceLayout.cpp",
"MyGUIEngine/src/MyGUI_ResourceManualFont.cpp",
"MyGUIEngine/src/MyGUI_ResourceManualPointer.cpp",
"MyGUIEngine/src/MyGUI_ResourceSkin.cpp",
"MyGUIEngine/src/MyGUI_RotatingSkin.cpp",
"MyGUIEngine/src/MyGUI_ScrollViewBase.cpp",
"MyGUIEngine/src/MyGUI_SharedLayer.cpp",
"MyGUIEngine/src/MyGUI_SkinItem.cpp",
"MyGUIEngine/src/MyGUI_SubWidgetBinding.cpp",
"MyGUIEngine/src/MyGUI_TabItem.cpp",
"MyGUIEngine/src/MyGUI_TextureUtility.cpp",
"MyGUIEngine/src/MyGUI_TextView.cpp",
"Platforms/OpenGL/OpenGLPlatform/src/MyGUI_OpenGLTexture.cpp",
"Plugins/Plugin_StrangeButton/Plugin.cpp",
"Tools/FontViewer/FontPanel.cpp",
"Tools/LayoutEditor/Application.cpp",
"Tools/LayoutEditor/ColourPanel.cpp",
"Tools/LayoutEditor/Common.h",
"Tools/LayoutEditor/EditorState.cpp",
"Tools/LayoutEditor/EditorWidgets.cpp",
"Tools/LayoutEditor/MainMenuControl.cpp",
"Tools/LayoutEditor/PanelControllers.cpp",
"Tools/LayoutEditor/PanelItems.cpp",
"Tools/LayoutEditor/ProjectControl.cpp",
"Tools/LayoutEditor/PropertyFieldPosition.cpp",
"Tools/LayoutEditor/PropertyFieldSkin.cpp",
"Tools/LayoutEditor/SettingsManager.cpp",
"Tools/LayoutEditor/TextureControl.cpp",
"Tools/LayoutEditor/WidgetCreatorManager.cpp",
"Tools/LayoutEditor/WidgetSelectorManager.cpp",
"Tools/LayoutEditor/WidgetStyle.h",
"Tools/LayoutEditor/WidgetTypes.cpp",
"Tools/LayoutEditor/WorkspaceControl.cpp",
"Tools/SkinEditor/MainMenuControl.cpp",
"Tools/SkinEditor/PropertyColourControl.cpp",
"Tools/SkinEditor/PropertyTexturesControl.cpp",
"Tools/SkinEditor/RegionTextureControl.cpp",
"Tools/SkinEditor/SeparatorTextureControl.cpp",
"Tools/SkinEditor/SettingsManager.cpp",
"Tools/SkinEditor/SkinTextureControl.cpp",
"Tools/SkinEditor/StateTextureControl.cpp",
"Tools/SkinEditor/TextureControl.cpp",
};

foreach (string file in files)
{
TranslateFileToUtf8(file);
}
}

Altren

21-09-2011 13:46:59

Your patch worked for me. I applied and commited it. Thank you for help.

zombielei

22-09-2011 08:18:48

Your patch worked for me. I applied and commited it. Thank you for help.
Hi Altren,the patch which i posted yesterday is for opengl build environment.This patch is for other build environments.
Thanks.

Altren

22-09-2011 08:45:03

Done. Thank you so much.