Raised This Month: $51 Target: $400
 12% 

KeyValue key behaves differently between \ and / slashes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-23-2014 , 16:22   KeyValue key behaves differently between \ and / slashes
Reply With Quote #1

...did you know ?

PHP Code:
new String:example_one[][] = {
    
"folder00/folder01/folder02",
    
"folder10/folder11/folder12",
    
"folder20/folder21/folder22"
}

new 
String:example_two[][] = {
    
"folder30\\folder31\\folder32",
    
"folder40\\folder41\\folder42",
    
"folder50\\folder51\\folder52"
}

public 
OnPluginStart()
{
    new 
Handle:kv CreateKeyValues("testing");

    
KvJumpToKey(kv"example_one"true);
    for(new 
0sizeof(example_one); a++)
    {
        
KvSetString(kvexample_one[a], "value");
    }
    
KvRewind(kv);


    
KvJumpToKey(kv"example_two"true);
    for(new 
0sizeof(example_two); a++)
    {
        
KvSetString(kvexample_two[a], "value");
    }
    
KvRewind(kv);


    
KeyValuesToFile(kv"output.txt");
    
CloseHandle(kv);

Code:
"testing"
{
	"example_one"
	{
		"folder00"
		{
			"folder01"
			{
				"folder02"		"value"
			}
		}
		"folder10"
		{
			"folder11"
			{
				"folder12"		"value"
			}
		}
		"folder20"
		{
			"folder21"
			{
				"folder22"		"value"
			}
		}
	}
	"example_two"
	{
		"folder30\folder31\folder32"		"value"
		"folder40\folder41\folder42"		"value"
		"folder50\folder51\folder52"		"value"
	}
}
Bacardi is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 07-23-2014 , 16:32   Re: KeyValue key behaves differently between \ and / slashes
Reply With Quote #2

That is interesting O_O
WildCard65 is offline
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 07-23-2014 , 20:27   Re: KeyValue key behaves differently between \ and / slashes
Reply With Quote #3

'\' is an escape character in KV.
The '/' subkey feature has existed for a while: https://mxr.alliedmods.net/hl2sdk-sd...Values.cpp#923
__________________
VoiDeD is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-25-2014 , 18:40   Re: KeyValue key behaves differently between \ and / slashes
Reply With Quote #4

Quote:
Originally Posted by VoiDeD View Post
'\' is an escape character in KV.
The '/' subkey feature has existed for a while: https://mxr.alliedmods.net/hl2sdk-sd...Values.cpp#923
Last I checked, escape characters are turned off on KV unless you explicitly turn them on. In SourcePawn, this is done with the KvSetEscapeSequences command.

Edit: Incidentally, the / "feature" explains a bug I've seen before when trying to check if a key exists and the key itself is a filepath.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-26-2014 at 04:36.
Powerlord is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode