codebude / QRCoder

A pure C# Open Source QR Code implementation
MIT License
4.56k stars 1.09k forks source link

vCard State #146

Closed Swisslogic closed 5 years ago

Swisslogic commented 5 years ago

Type of issue

[ ] Bug
[X] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement

Expected Behavior

Current Behavior

Thank you for the incredible work! PayloadGenerator.ContactData() is missing "State" such as Florida. I know you don't use such a field in Europe. How could this be added? Also, how would one create a payload from scratch for vCards? Or am I missing something? Thank you again and sunny greetings from Florida

Possible Solution (optional)

Steps to Reproduce (for bugs)

Your Environment

DevonJSmith commented 5 years ago

The second part of your question, how to create a vCard/MeCard payload from scratch is answered by this section of the wiki: https://github.com/codebude/QRCoder/wiki/Advanced-usage---Payload-generators#35-contactdata-mecardvcard

In particular, these two lines will be relevant:

ContactData generator = new ContactData(ContactData.ContactOutputType.VCard3, "John", "Doe");
string payload = generator.ToString();

The ContactData constructor has optional parameters for all of the attributes, only the First Name and Last Name are needed.

However, you have brought up a good point, State (such as in the case of the US) is not an available parameter and it should be. According to the RFC 2426:

Type special notes: The structured type value consists of a sequence of address components. The component values MUST be specified in their corresponding position. The structured type value corresponds, in sequence, to the post office box; the extended address; the street address; the locality (e.g., city); the region (e.g., state or province); the postal code; the country name. When a component value is missing, the associated component separator MUST still be specified.

I would recommend that this issue be used as a feature request to add Region/State support to the ContactData class in PayloadGenerator.cs

codebude commented 5 years ago

Done with PR: https://github.com/codebude/QRCoder/pull/149